首页 > 解决方案 > 播种我的 Heroku hobbydev Postgres 数据库

问题描述

我知道这在过去被问了很多,但我根本没有运气。我已经成功地将一个简单的 Rails 博客应用程序推送到 heroku。问题是我使用 ruby​​ faker gem 填充的种子文件即使在我运行heroku run rake db:seedheroku run rails db:seed. 我不知道此时我还能做什么。我查看了无数其他堆栈问题,他们都说了同样的话,那就是运行我刚刚列出的 2 个命令。有什么建议么?我需要重置我的生产数据库吗?

编辑:这是种子文件

5.times do 
    Article.create([{ 
        title: "The IT Crowd",
        body: Faker::TvShows::TheITCrowd.quote,
        status: "public",
        user_id: 2
    }])
end

5.times do 
    Article.create([{ 
        title: "Bojack Horseman",
        body: Faker::TvShows::BojackHorseman.quote,
        status: "public",
        user_id: 2
    }])
end
5.times do 
        Article.create([{ 
        title: "The Big Lebowski",
        body: Faker::Movies::Lebowski.quote,
        status: "public",
        user_id: 2
    }])
end
5.times do 
    Article.create([{ 
    title: "Recipe",
    body: Faker::Food.description,
    status: "public",
    user_id: 2
}])
end

这是我的文章模型

class Article < ApplicationRecord
    include Visible
    belongs_to :user
    has_many :comments, dependent: :destroy
    has_rich_text :body
    validates :title, presence: true
    validates :body, presence: true, length: { minimum: 10 }
  end

先感谢您!

标签: ruby-on-railsrubyheroku-postgresheroku-cli

解决方案


推荐阅读