我正在使用acts_as_audited
作为gem /插件安装的glassfish上部署我的Jruby Rails应用程序。
每当我尝试审核我的模型时,我都会收到以下错误。
我的环境是: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...
答案 0 :(得分: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
我不确定为什么会发生这种情况,但这可能是与线程安全模式下的生产相关的加载/解决问题。
答案 1 :(得分:1)
我在jruby-rack中将此问题报告为a bug。
解决方法是在{/ 1}}之后的config / boot.rb中添加require 'active_record' if defined? $servlet_context
,或在application.rb require 'rubygems'
中手动包含扫描somwhere。