所以我觉得我很愚蠢,很长一段时间没有检查生产环境中的运行情况,现在我正在尝试部署,我遇到了这个恼人的错误。有什么想法吗?
lib/history_tools.rb
module HistoryTools
def self.included(base)
base.has_many :history, :dependent => :destroy
History::TYPES.each do |htype|
base.has_many "history_#{htype}", :class_name => "History::#{htype.capitalize}"
end
end
# ... other minor things removed ...
end
应用程序/模型/user.rb
class User < InheritedResources::Base
include HistoryTools
end
配置/环境.rb
# ... the usual stuff, then, at the very bottom:
require 'history_tools'
这给出了错误:
activesupport-2.3.8/lib/active_support/dependencies.rb:417:in
`load_missing_constant':ArgumentError: Object is not missing
constant HistoryTools!
如果我在 user.rb 顶部添加一个额外的 require 'history_tools'
,我相信它会修复那个错误,但随后它无法找到其他东西在#{RAILS_ROOT}/lib
中,以相同的方式在environment.rb中需要这些。
最重要的是:这在开发模式下完美运行。它仅在生产中给出此错误。我的大部分谷歌搜索似乎都表明“不丢失常量”错误与 Rails 自动加载文件的方式有关,当没有卸载任何内容时,这些错误应该在生产中消失。这似乎与那种行为相反?
最佳答案
当我收到此错误时,这是因为错误中提到的类/模块内的内部类/模块存在错误。
关于ruby-on-rails - Rails,生产环境, "Object is not missing constant",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4056894/