2015-08-13 8 views
19

Ich versuche, die Schienen zu laufen (4.1.2) KonsoleErste config.eager_load wird auf Null gesetzt, während versuchen, Schienen c in Test

rails c RAILS_ENV=test 

Und ich bin immer diese auszuführen:

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

Doch in meinem test.rb ich habe config.eager_load = false und meine database.yml ok ist (ich lief rake db:schema:load RAILS_ENV=test ohne Probleme.

Wie kann ich dieses Problem lösen?

Antwort

24

Sie müssen die env erklären, bevor Sie die Befehle ausführen:

RAILS_ENV=test bundle exec rails c 

ich die gleiche Leistung auf meinem Computer erhalten:

> 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 

aber wenn ich wie vorgeschlagen laufen:

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

Danke! Für mich geht das. –

1

Wie für Windows-Systeme:

  1. sollte dies tun:

    rails c -e test 
    
  2. Oder setzen Sie die RAILS_ENV Variable zuerst:

    set RAILS_ENV=test 
    rails c 
    
0

Unter Windows gibt es einen Glitch mit RAILS_ENV. Wenn Sie

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

laufen, dann werden Sie den Fehler:

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

wenn rails server webrick tun.

So stellen Sie sicher, tun Sie Typ ohne Leerzeichen am Ende (und ohne Anführungszeichen)

SET RAILS_ENV=development<ENTER> 

Das gleiche gilt für alle Umgebungen: Test, Produktion und Entwicklung.