简体   繁体   中英

RAILS_ENV=dev bundle exec rake db:seed not working

I have written this code

namespace :db do
  task :seed, :only => {:primary => true}, :except => { :no_release => true } do 
    rails_env = ENV["RAILS_ENV"]
    current_path = File.dirname(__FILE__)
    run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake db:seed"
  end
end

and I am calling db.seed after deploy:migrate

This code is working on my test environment but not on dev or integration environment. Its showing this error :

rake aborted!
undefined method `[]' for nil:NilClass
/Users/Megha/Documents/Mckinsey project/LeanITAppServer/config/initializers/authentication.rb:6:in `<top (required)>'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/engine.rb:587:in `each'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/engine.rb:587:in `block in <class:Engine>'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/Megha/Documents/Mckinsey project/LeanITAppServer/config/environment.rb:6:in `<top (required)>'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/application.rb:103:in `require'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:346:in `block (2 levels) in <top (required)>'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/bin/ruby_noexec_wrapper:14:in `eval'
/Users/Megha/.rvm/gems/ruby-1.9.3-p392@bto/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:abort_if_pending_migrations => environment

Can anyone tell me what's the problem

Use this command line

RAILS_ENV=development bundle exec rake db:seed

And if it does not work you could post the content of the file /config/initializers/authentication.rb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM