Rails5でdb:migrateしたら「Directly inheriting from ActiveRecord::Migration is not supported.」とエラーが出た
最終更新から9年以上たっています。ライブラリのバージョンや手順が変わっている可能性があります。
Rails 5.1.4でactiverecord-session_storeを使おうと思い、以下のコマンドを実行した。
rails g active_record:session_migration
rails db:migrate
すると、以下のエラーが出た。
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
なんだこれはと思い検索すると、毎度のstackoverflowに答えが。
specifying Rails version in migration files
activerecord-session_storeとは違うgemのissueだけど、解決法はmigrationのファイルを修正する事だった。
class AddSessionsTable < ActiveRecord::Migration
↓ こう変更する
class AddSessionsTable < ActiveRecord::Migration[5.1]
これで再度db:migrateを行ったところ、無事テーブルが作成された。
Ruby・Rails の記事
コメントの受け付けは終了しました。ご意見・ご質問は X(@nm_aru)へどうぞ。
コメント(1件)
Thank you for the useful information.