在开发模式下一切正常,但是当我尝试在生产模式下启动我的应用程序(RAILS_ENV =生产脚本/服务器)时,我收到以下错误:
/opt/ruby1.8/lib/ruby/gems/1.8/gems/searchlogic-2.4.19/lib/searchlogic/named_scopes/conditions.rb:81:in `method_missing': protected method `scope' called for #<Class:0x7f41de524410> (NoMethodError)
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/searchlogic-2.4.19/lib/searchlogic/named_scopes/association_conditions.rb:19:in `method_missing'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/searchlogic-2.4.19/lib/searchlogic/named_scopes/association_ordering.rb:27:in `method_missing'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/searchlogic-2.4.19/lib/searchlogic/named_scopes/ordering.rb:30:in `method_missing'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/searchlogic-2.4.19/lib/searchlogic/named_scopes/or_conditions.rb:28:in `method_missing'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in `method_missing_without_paginate'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:170:in `method_missing'
from /opt/ruby1.8/lib/ruby/gems/1.8/gems/acts_as_commentable-3.0.0/lib/comment_methods.rb:12:in `included'
from .../app/models/comment.rb:2:in `include'
from .../app/models/comment.rb:2
from /opt/ruby1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/ruby1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'...
现在在我看来,acts_as_commentable gem导致了这一点。但是,为什么它在开发模式下工作正常。
答案 0 :(得分:1)
在开发模式类中,您可以根据需要加载它们。在生产中,它们在轨道启动时被缓存。
答案 1 :(得分:1)
由于fl00r的评论,我发现了错误:
显示comment.rb(第2行)
comment.rb中的第2行是include ActsAsCommentable::Comment
。这对我来说有点奇怪,所以我看了一下acts_as_commentable gem的官方文档。那就是问题所在。应该是acts_as_commentable
。必须从某个地方复制粘贴它。
尽管如此,神秘仍然是它如何在开发模式中发挥作用。由于annaswims提到的类缓存?