【发布时间】:2016-06-25 10:14:27
【问题描述】:
我之前已经发布过这个问题,但我没有任何答案可以解决我的问题。因此,我重新发布这个问题。
我正在使用 heroku 来部署我的 rails 应用程序。我试图通过运行命令heroku run rake db:seed. 在生产中播种一些数据但是,该命令不起作用。我无法在生产中播种文件。 seeds.rb 文件如下所示。
#This file should contain all the record creation needed to seed the database with its default values.
#The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#Examples:
#cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#Mayor.create(name: 'Emanuel', city: cities.first)
#end
5.times do
Scoreboard.create!(name_of_scoreboard: "scoreboard_abc",
name_of_organization: "abcdef",
name_of_activity: "ghijklmn",
user_id: 1,
states: "state",
country: "state",
cities: "state")
end
$ heroku run rake db:seed 在 ⬢ 应用程序上运行 rake db:seed... up, run.4751 ActiveRecord::SchemaMigration Load (2.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
我运行heroku restart,但对象没有在生产数据库中播种。我已尝试在开发中播种此文件,并且效果很好。我不确定出了什么问题。
heroku 日志 -t 文件如下所示。
2016-06-22T00:50:58.882699+00:00 heroku[api]: Starting process with command `bundle exec rake db:seed` by *******@gmail.com
2016-06-22T00:51:07.986301+00:00 heroku[run.1041]: Awaiting client
2016-06-22T00:51:08.026539+00:00 heroku[run.1041]: Starting process with command `bundle exec rake db:seed`
2016-06-22T00:51:08.157630+00:00 heroku[run.1041]: State changed from starting to up
2016-06-22T00:51:12.891248+00:00 heroku[run.1041]: State changed from up to complete
2016-06-22T00:51:12.881329+00:00 heroku[run.1041]: Process exited with status 0
我有 database.yml 文件和 seed.rb 文件作为 gitignore 的一部分。我不确定这是否是问题的原因。我很确定它不是。
【问题讨论】:
-
您是否查看过
heroku logs --tail以找到您的种子的错误? -
@maxpleaner,我还没有,但我现在会看看它并发布日志文件。
-
@maxpleaner,我已经发布了 heroku 的实时日志文件。不确定发生了什么,但发布请求没有通过
-
所以日志显示没有错误。您有多确定种子命令“不起作用”?你检查过控制台是否有记录吗?
-
@maxpleaner,是的,我将最新更改推送到 heroku。我运行了 heroku run rake db:migrate,迁移很适合投入生产。我能够在生产中注册用户就好了。
标签: ruby-on-rails ruby heroku