2015-08-13 14 views
19

sto cercando di eseguire i binari (4.1.2) consoleOttenere config.eager_load è impostato a zero durante il tentativo di eseguire rotaie c in prova

rails c RAILS_ENV=test 

e sto ottenendo questo:

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

Eppure nel mio test.rb ho config.eager_load = false e il mio database.yml è ok (I corse rake db:schema:load RAILS_ENV=test senza problemi.

Come posso risolvere questo problema?

risposta

24

è necessario dichiarare l'ENV prima di eseguire i comandi:

RAILS_ENV=test bundle exec rails c 

ottengo lo stesso output sul mio computer:

> 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 

ma quando ho eseguito come suggerito:

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

Grazie! Per me funziona. –

1

Come per i sistemi Windows:

  1. Questo dovrebbe fare:

    rails c -e test 
    
  2. o impostare la prima RAILS_ENV variabile:

    set RAILS_ENV=test 
    rails c 
    
0

Su Windows c'è un problema tecnico con RAILS_ENV. Se si esegue

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

allora si otterrà l'errore:

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

quando si fa rails server webrick.

Quindi assicuratevi di fare il tipo senza spazio finale (e senza virgolette)

SET RAILS_ENV=development<ENTER> 

Lo stesso vale per tutti gli ambienti: prova, produzione e sviluppo.

Problemi correlati