paper_trail: Unable to join versions association

When upgrading Paper Trail from 8.1.2 to 0e94b68c232253b28178e73d129157a2f68e2954, we started running into a Rails error anywhere we performed a join:

>> User.joins(:versions).to_a

ArgumentError: The association scope 'versions' is instance dependent (the scope block takes an argument). 
Preloading instance dependent scopes is not supported.

from gems/activerecord-5.1.5/lib/active_record/reflection.rb:481:in `check_preloadable!'

What inside Paper Trail caused this error? Is it something we’ll have to upgrade Rails to fix?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Another option would be to rely on the inherited callback, redefining the association on every STI child class that’s defined.