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>)
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!
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.
We just went into production and we're starting to see this error crop up. Should we give cattr_accessor a try?
close #307, close #326, close #328; Make Model.paper_trail_enabled_fo…