1

I'm building an app which has a plan model, and a users model. The plan model has_many users, and is responsible for plan details, price etc.

What I'd like to do, is to build a rake tasks which allows me to create 3 plans in heroku. I've been messing around with the code, but keep on getting the error, when I run heroku run rake db:populate_plans

Don't know how to build task 'production'

Here's the code written for it :

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

Any guidance on this is greatly appreciated!

4

1 に答える 1

0

これを試して

namespace :db do
  desc "fill in plans"
  task :populate_plans => :environment 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

rake db:populate_plans RAILS_ENV=productionを実行します

于 2012-10-08T04:38:33.787 に答える