ruby-on-rails - 播种我的 Heroku hobbydev Postgres 数据库
问题描述
我知道这在过去被问了很多,但我根本没有运气。我已经成功地将一个简单的 Rails 博客应用程序推送到 heroku。问题是我使用 ruby faker gem 填充的种子文件即使在我运行heroku run rake db:seed
或heroku 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
先感谢您!
解决方案
推荐阅读
- python - 在 train_test_split sklearn 中随机定义训练大小
- c++ - 结构内的C ++可变数组长度
- sql - Redshift:Javascript 时间格式 Varchar 字段的日期比较
- c++ - HDF5 简单读取数据集失败
- javascript - 显示一定时间后如何隐藏或删除消息?
- python - 已部署 GAE NDB 安装
- javascript - Moment.js:将持续时间分割为年、月、周、日等
- javascript - d3.js:渐变填充是轮廓,如何使它变得立体?
- android - 使用 Surfaceview 尺寸调整相机视图
- google-pay - 使用 3ds 在网络上支付 Google Pay