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
- Revert #1108 (lorint's STI fix) This partially reverts commit 58369e1d8fe16ae7f37dee3da05c120827afdf3e. I have kept the specs, skipped. Per the following, this approach does not seem to be working: ... — committed to paper-trail-gem/paper_trail by jaredbeck 6 years ago
- Revert #1108 (lorint's STI fix) This partially reverts commit 58369e1d8fe16ae7f37dee3da05c120827afdf3e. I have kept the specs, skipped. Per the following, this approach does not seem to be working: ... — committed to aried3r/paper_trail by jaredbeck 6 years ago
Another option would be to rely on the
inheritedcallback, redefining the association on every STI child class that’s defined.