paper_trail-association_tracking: Problem loading after upgrading to paper_trail 12.0

Just upgraded to paper_trail 12.0 today. Now when I try:

require “paper_trail” require “paper_trail-association_tracking”

I get an error:

/ruby-2.5.3/gems/paper_trail-association_tracking-2.1.1/lib/paper_trail_association_tracking/version_concern.rb:19:in block in <module:VersionConcern>': undefined method scope’ for PaperTrail::VersionConcern:Module (NoMethodError)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 23
  • Comments: 22 (14 by maintainers)

Most upvoted comments

Looking real good. Send out that PR and I can work on Rails 7 if no one else wants to.

Dang. I didn’t realize this would impact PT-AT. For the short-term, PT-AT users can constrain PT to < 12 without missing much.

I learned a bunch about Railties in the process of working on https://github.com/paper-trail-gem/paper_trail/pull/1281, let me know if I can help answer any questions about load order. I also documented some of what I learned in comments in paper_trail-12.0.0/lib/paper_trail/frameworks/rails/railtie.rb, if that helps.

v2.2.0 is now released which contains the necessary changes for PT 12+ to function correctly.

Still looking for a PR here if anyone can come up with something that works. Would be a big help to the PT community.

@westonganger here are the results of my build. As you can see, I still have failed builds, but they are all related to Rails 7.

An error occurred while loading spec_helper.
Failure/Error:
  @model_class.send(:"before_#{verb}_for_#{assoc_name}").send(
    :<<,
    lambda do |*args|
      update_habtm_state(assoc_name, :"before_#{verb}", args[-2], args.last)
    end
  )

NoMethodError:
  undefined method `before_add_for_foo_habtms' for BarHabtm (call 'BarHabtm.connection' to establish a connection):Class

I would like to point out the changes I made that did not resolve our issues. So that others can learn from my experiences.

Commit: https://github.com/westonganger/paper_trail-association_tracking/commit/a84cd2e5798328a9ae0eddb6e130f750a614fc2f

No guarantees but I’ll give it a go. I’ll look into it first thing in the morning.

Its appears this is related to https://github.com/paper-trail-gem/paper_trail/pull/1281 where they switched to a different loading/initialization methodology. We will need to lazy load our files in a similar manner.

PR wanted if anyone wants to take a stab at it, otherwise I will try to look into this soon.