【问题标题】:Ruby on Rails App not starting in production modeRuby on Rails 应用程序未在生产模式下启动
【发布时间】:2010-05-12 16:51:01
【问题描述】:

在开发模式下一切正常,但是当我尝试在生产模式下启动我的应用程序 (RAILS_ENV=production script/server) 时出现以下错误:

/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 导致了这种情况。但是怎么回事,在开发模式下还是可以正常使用的。

【问题讨论】:

  • 显示 comment.rb(第 2 行附近)

标签: ruby-on-rails development-environment production-environment


【解决方案1】:

在开发模式下,类会根据需要加载。在生产环境中,它们会在 rails 启动时被缓存。

【讨论】:

    【解决方案2】:

    感谢 fl00r 的评论,我发现了错误:

    显示 comment.rb(第 2 行附近)

    comment.rb 中的第 2 行是 include ActsAsCommentable::Comment。这对我来说有点奇怪,所以我查看了acts_as_commentable gem 的官方文档。这就是问题所在。它应该是acts_as_commentable。一定是从某个地方复制粘贴的。

    不过,它如何在开发模式下工作仍然是个谜。因为annawims提到的类缓存?

    【讨论】:

      猜你喜欢
      • 2011-07-07
      • 2013-05-25
      • 1970-01-01
      • 2022-08-09
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 2014-11-29
      • 2014-03-05
      相关资源
      最近更新 更多