2011-02-11 49 views
2

我在Glassfish上部署我的Jruby Rails應用程序,acts_as_audited作爲安裝的gem/plugin。未定義的方法`cache_sweeper'爲ActionController :: Base:Class - warbler

每當我嘗試審計我的模型,我將得到以下錯誤。

我的環境是:JRuby的1.6.0.RC2來說,Rails 3.0.3

你可以參考這裏,如果你們想要看更多的錯誤http://www.ruby-forum.com/topic/1053934

請幫我,我卡住了這裏

Application Error 
org.jruby.rack.RackInitializationException: undefined method `cache_sweeper' for ActionController::Base:Class 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/acts_as_audited-2.0.0.rc6/lib/acts_as_audited.rb:44:in `class_eval' 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/acts_as_audited-2.0.0.rc6/lib/acts_as_audited.rb:44 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/acts_as_audited-2.0.0.rc6/lib/acts_as_audited.rb:68:in `require' 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require' 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each' 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require' 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each' 
    from /home/dev2/glassfishv3/glassfish/domains/domain1/applications/gavel/WEB-INF/gems/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require' 
    ... 20 levels... 

回答

1

我在jruby-rack中報告了這個問題爲a bug

解決方法是在config/boot.rb中的require 'rubygems'之後添加require 'active_record' if defined? $servlet_context,或手動包括在application.rb ActionController::Base.send(:include, ActionController::Caching::Sweeping) if defined? $servlet_context中掃描somwhere。

1

我想我認識到這個問題。它看起來像acts_as_audited使用緩存清理器。我遇到了高速緩存清掃器的這個問題。

你需要明確在您的ApplicationController緩存模塊:

class ApplicationController < ActionController::Base 

    # JRuby not finding cache sweeper at runtime in production 
    include ActionController::Caching::Sweeping if defined?(JRUBY_VERSION) 

    # Rest of your class here... 

end 

我不知道爲什麼會這樣,但它可能關係到線程模式下運行生產的裝載/解析問題。

+0

更新:我已經發現了以下Rails Lighthouse門票,表明清掃車不是線程安全的。您可能會遇到其他問題。但是,有一個解決方法。 https://rails.lighthouseapp.com/projects/8994/tickets/3457-actioncontrollercachingsweeper-controller-instance-is-not-thread-safe – Scott 2011-02-14 13:26:25

相關問題