Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 在尝试在测试中运行rails c时,将config.eager_load设置为nil大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图运行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:scheR_985_11845@a: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)

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – 在尝试在测试中运行rails c时,将config.eager_load设置为nil全部内容,希望文章能够帮你解决ruby-on-rails – 在尝试在测试中运行rails c时,将config.eager_load设置为nil所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。