sau*_*kko 24 ruby environment config ruby-on-rails
我正在尝试运行rails(4.1.2)控制台
rails c RAILS_ENV=test
Run Code Online (Sandbox Code Playgroud)
我得到了这个:
> 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)
Run Code Online (Sandbox Code Playgroud)
然而,在我的test.rb我config.eager_load = false和我database.yml的确是好的(我rake db:schema:load RAILS_ENV=test没有问题.
我怎么解决这个问题?
Ian*_*lby 29
您需要在运行命令之前声明env:
RAILS_ENV=test bundle exec rails c
Run Code Online (Sandbox Code Playgroud)
我在计算机上得到相同的输出:
> 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
Run Code Online (Sandbox Code Playgroud)
但是当我按照建议运行时:
> RAILS_ENV=test bundle exec rails c ian@Ians-MacBook-Pro
Loading test environment (Rails 4.2.3)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13529 次 |
| 最近记录: |