我建立具有计划模型的应用和用户模式。该计划模型的has_many用户,并负责计划的细节,价格等Rake任务错误:不知道如何建设任务“生产”
我今天准备这样做,是要建立一个rake任务,让我创造的Heroku 3个计划。我一直在插科打诨的代码,但不断得到错误,当我运行heroku run rake db:populate_plans
Don't know how to build task 'production'
下面是它编写的代码:
namespace :db do
desc "fill in plans"
task populate_plans: :production do
Plan.create!(name: "Professional", max_phone_numbers: "5", max_minutes: "500", price: "49.95")
Plan.create!( name: "Small Business", max_phone_numbers: "10", max_minutes: "1000", price: "99.95")
Plan.create!(name: "Office", max_phone_numbers: "25", max_minutes: "2000", price: "149.95")
end
end
对此有何指导是非常感谢!
你的任务被命名为'分贝:populate_plans' ... –
...哇,这是愚蠢的我。改为Heroku的运行耙分贝:populate_plans,但现在我得到的错误:不知道如何运行任务“生产”。思考? –
1.为什么不使用种子? 2.您是否尝试将':production'更改为':environment'? –