Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting config.eager_load is set to nil while trying to run rails c in test

I'm trying to run the rails (4.1.2) console

rails c RAILS_ENV=test 

And I'm getting this:

> config.eager_load is set to nil. Please update your > config/environments/*.rb files accordingly: >  >   * development - set it to false   * test - set it to false (unless > you use a tool that preloads your test environment)   * production - > set it to true >  > /Users/xxxxxx/.rvm/gems/ruby-2.2.2/gems/activerecord-4.1.12/lib/active_record/connection_adapters/connection_specification.rb:257:in > `resolve_symbol_connection': 'RAILS_ENV=test' database is not > configured. Available: ["development", "test", "production"] > (ActiveRecord::AdapterNotSpecified) 

Yet in my test.rb I have config.eager_load = false and my database.yml is ok (I ran rake db:schema:load RAILS_ENV=test without issues.

How can I solve this?

like image 916
sauronnikko Avatar asked Aug 13 '15 22:08

sauronnikko


2 Answers

You need to declare the env before you run the commands:

RAILS_ENV=test bundle exec rails c 

I get the same output on my computer:

> bundle exec rails c RAILS_ENV=test                                                                                                               ian@Ians-MacBook-Pro config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:    * development - set it to false   * test - set it to false (unless you use a tool that preloads your test environment)   * production - set it to true 

but when I run as suggested:

> RAILS_ENV=test bundle exec rails c                                                                                                               ian@Ians-MacBook-Pro Loading test environment (Rails 4.2.3) 
like image 96
Ian Selby Avatar answered Sep 28 '22 04:09

Ian Selby


Needs to set

config.eager_load = false 

for config/environments/development.rb and test.rb or = true for production.rb (as default)

like image 34
dostapn Avatar answered Sep 28 '22 06:09

dostapn