【问题标题】:rails runner throws incorrect error: "config.eager_load is set to nil"rails runner 抛出不正确的错误:“config.eager_load 设置为 nil”
【发布时间】:2016-08-15 12:22:55
【问题描述】:

我很难运行 rails runner(在 rails 版本 4.2.6 中)。

以下每个命令都会引发错误“config.eager_load is set to nil”,即使此值已在所有环境文件中正确设置。

bin/rails runner -e "MyClass.my_method"
bundle exec rails runner =e "MyClass.my_method"

bin/rails runner -e "MyClass.my_method" RAILS_ENV=development
bundle exec rails runner =e "MyClass.my_method" RAILS_ENV=development

RAILS_ENV=development bin/rails runner -e "MyClass.my_method"
RAILS_ENV=development bundle exec rails runner -e "MyClass.my_method"

运行 rails runner 的正确方法是什么?

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-4 ruby-on-rails-4.2


【解决方案1】:

这里是有关运行 runner 正确方法的文档:http://guides.rubyonrails.org/command_line.html#rails-runner 这意味着它可能是

bin/rails runner -e development "MyClass.my_method"

注意:我始终建议您阅读所有 Rails 指南,如果您还没有 - 它们是升级 Rails 的最佳方式之一。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-17
    • 1970-01-01
    • 2016-03-11
    • 1970-01-01
    • 2015-09-22
    • 2014-03-11
    • 1970-01-01
    相关资源
    最近更新 更多