LoginSignup
0
0

More than 3 years have passed since last update.

ActiveModel::UnknownAttributeError: unknown attribute 'foreign_type' for PaperTrail::VersionAssociation のエラー対応

Last updated at Posted at 2020-08-05

起こったこと

rails db:migrateしたら以下のようなエラーを吐いた。
エラー文を読むと、「VersionAssociation テーブルに foreign_type カラムがない!」と怒られている。

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

原因

paper_trailというgemをアップデートしたことで発生。
公式リポジトリのCHANGELOG.mdを見るとforeign_typeに関する記述を発見。。

How to Upgrade from v1.0.0 or earlier
Run rails g paper_trail_association_tracking:add_foreign_type_to_version_associations and then migrate your database.

カラムを追加するマイグレーションファイルを作成してから rails db:migrateすればよさそう。

解決方法

terminal
# カラムを追加するマイグレーションファイルを作成
rails g paper_trail_association_tracking:add_foreign_type_to_version_associations
# 作成したマイグレーションファイルを適応
rails db:migrate

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0