Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError (undefined method `paper_trail_enabled_for_model') #307

Closed
dwbutler opened this issue Dec 5, 2013 · 3 comments
Closed

NoMethodError (undefined method `paper_trail_enabled_for_model') #307

dwbutler opened this issue Dec 5, 2013 · 3 comments
Assignees
Milestone

Comments

@dwbutler
Copy link
Contributor

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/RubyBasicObject.java:1497:in `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
Copy link
Collaborator

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.

@dwbutler
Copy link
Contributor Author

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.

@ghost ghost assigned batter Jan 14, 2014
@dwbutler
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants