new_user
new_user

Reputation: 81

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

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.

Upvotes: 5

Views: 1167

Answers (1)

Ganesh
Ganesh

Reputation: 2004

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

Upvotes: 7

Related Questions