加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 在尝试在测试中运行rails c时,将config.eager_

发布时间:2020-12-16 20:30:41 所属栏目:百科 来源:网络整理
导读:我试图运行rails(4.1.2)控制台 rails c RAILS_ENV=test 我得到这个: 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 too
我试图运行rails(4.1.2)控制台
rails c RAILS_ENV=test

我得到这个:

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

然而在我的test.rb我有config.eager_load = false和我的database.yml是好的(我运行rake db:schema:load RAILS_ENV = test没有问题.

我该如何解决?

解决方法

在运行命令前需要声明env:
RAILS_ENV=test bundle exec rails c

我在我的电脑上得到相同的输出:

> 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

但是当我按照建议运行时:

> RAILS_ENV=test bundle exec rails c                                                                                                               ian@Ians-MacBook-Pro
Loading test environment (Rails 4.2.3)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读