2015-08-13 24 views
19

Próbuję uruchomić szyny (4.1.2) konsoliPierwsze config.eager_load jest ustawiony na zero, podczas próby uruchomienia ceowniki w teście

rails c RAILS_ENV=test 

A ja dostaję to:

> 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) 

Jednak w moim test.rb mam config.eager_load = false i mój database.yml jest ok (Pobiegłem rake db:schema:load RAILS_ENV=test bez problemów.

Jak mogę rozwiązać ten problem?

Odpowiedz

24

Musisz zadeklarować env przed uruchomieniem polecenia:

RAILS_ENV=test bundle exec rails c 

mogę uzyskać taki sam efekt na moim komputerze:

> bundle exec rails c RAILS_ENV=test                            [email protected] 
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 

ale kiedy biegnę jak sugeruje:

> RAILS_ENV=test bundle exec rails c                            [email protected] 
Loading test environment (Rails 4.2.3) 
+0

Dzięki! Mi to pasuje. –

1

W przypadku systemów Windows:

  1. ten powinien zrobić:

    rails c -e test 
    
  2. lub ustawić RAILS_ENV zmienna pierwszy:

    set RAILS_ENV=test 
    rails c 
    
0

W Windows jest glitch z RAILS_ENV. Jeśli prowadzisz

SET RAILS_ENV=development<SPACE> <- with a space symbol after word "development" 

wtedy pojawia się błąd:

config.eager_load is set to nil. Please update your config/environments/*.rb fil es accordingly:

robiąc rails server webrick.

więc upewnij się zrobić bez spacji typu wleczonego (i nie cudzysłowów)

SET RAILS_ENV=development<ENTER> 

To samo odnosi się do wszystkich środowisk: Test, produkcji i rozwoju.