Skip to content

NoMethodError (undefined method `paper_trail_enabled_for_model') #307

dwbutler opened this Issue Dec 5, 2013 · 3 comments

2 participants

dwbutler commented Dec 5, 2013

I'm in using Paper Trail in Rails / ActiveRecord 3.1.15 under JRuby in the Torquebox server. I haven't had any issues until I started load testing. Now, every now and then I see the following error:

NoMethodError (undefined method `paper_trail_enabled_for_model' for #<Class:0x160041f0>)
org/jruby/ `method_missing'
/shared/bundle/jruby/1.9/gems/activerecord-3.2.15/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
/shared/bundle/jruby/1.9/gems/activesupport-3.2.15/lib/active_support/core_ext/class/attribute.rb:129:in `paper_trail_enabled_for_model'
/shared/bundle/jruby/1.9/gems/paper_trail-2.7.2/lib/paper_trail/has_paper_trail.rb:175:in `without_versioning'

This is running inside a transaction, when a model is being created, in an after_save callback. All I can imagine is that ActiveSupport's class_attribute is somehow not thread-safe.

Any ideas? Thanks!

batter commented Dec 11, 2013

I've never felt strongly about the need for using class_attribute for a lot of the fields that it is applied to via the has_paper_trail declaration, but can't speak to whether it's thread-safe or not. The one nice thing about class_attribute is that it can be overridden by instances of a class, but somehow I doubt that users really use that functionality. Do we think that cattr_accessor is more thread-safe for some reason? Or perhaps they should just be defined using attr_accessor? I don't have much experience with JRuby.


Anything in core Ruby should be thread-safe these days, whether MRI or JRuby. I can't figure out either what is unsafe about class_attribute, but if it's possible to use core Ruby methods that might be a good idea.

@batter batter was assigned Jan 14, 2014
dwbutler commented Feb 6, 2014

We just went into production and we're starting to see this error crop up. Should we give cattr_accessor a try?

@batter batter added a commit that closed this issue Feb 20, 2014
@batter batter close #307, close #326, close #328; Make Model.paper_trail_enabled_fo…
…r_model? thread-safe
@batter batter closed this in 0359704 Feb 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.