ActiveModel::UnknownAttributeError: unknown attribute 'foreign_type' for PaperTrail::VersionAssociation
Asked Answered
S

1

5

I am migrating my application from Rails4.2.8 to Rails5.2.3, updated paper-trail gem version '7.1.2' to '10.3.1'.I am using Rspec - 3.8.2. Everything worked fine but my specs are failing for models which used 'has_paper_trail' macro.

Tried looking into my codes as well as gem repo, didn't found such attribute anywhere.

Found some similar issue but it didn't helped. https://github.com/paper-trail-gem/paper_trail/issues/455

ActiveModel::UnknownAttributeError:unknown attribute 'foreign_type' for PaperTrail::VersionAssociation.

Semite answered 6/8, 2019 at 13:17 Comment(3)
"updated paper-trail gem version 7 to 10" .. I strongly recommend updating one major version at a time. Update 7 to 8, make sure all tests pass, make sure all deprecation warnings are fixed, then update 8 to 9, etc.Cappella
Am also migrating and seeing this. Am going from Rails 5.3 -> 6.0.1, and paper_trail was already on 10.3.1.Indoctrinate
also dealing with this upgrading a very old app. Might just remove paper trailFuthark
K
7

You need to add column foreign_type into version_associations tables after upgrading gem paper_trail.

Run rails g paper_trail_association_tracking:add_foreign_type_to_version_associations and then migrate your database.

These changes were done in gem paper_trail-association_tracking which is one of the dependencies for paper_trail gem.

Ref: CHANGELOG

Kerley answered 16/1, 2020 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.