Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 524
new_user Avatar asked Aug 06 '19 13:08

new_user


1 Answers

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

like image 172
Ganesh Avatar answered Sep 28 '22 22:09

Ganesh