LoginSignup
1
0

More than 5 years have passed since last update.

Rails5 でfriendly_idを入れてからマイグレーションに失敗する時 when we failed to migrate because of friendly_id, how to solve the problem on Rails5

Last updated at Posted at 2018-01-25

エラー Error

rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateFriendlyIdSlugs < ActiveRecord::Migration[4.2]
/home/ekrem/Projects/ekomerz/db/migrate/20170308164827_create_friendly_id_slugs.rb:1:in `<top (required)>'
/home/ekrem/Projects/ekomerz/bin/rails:9:in `require'
/home/ekrem/Projects/ekomerz/bin/rails:9:in `<top (required)>'
/home/ekrem/Projects/ekomerz/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateFriendlyIdSlugs < ActiveRecord::Migration[4.2]
/home/ekrem/Projects/ekomerz/db/migrate/20170308164827_create_friendly_id_slugs.rb:1:in `<top (required)>'
/home/ekrem/Projects/ekomerz/bin/rails:9:in `require'
/home/ekrem/Projects/ekomerz/bin/rails:9:in `<top (required)>'
/home/ekrem/Projects/ekomerz/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

解決策 Soloution

ただ[5.1]をマイグレーションファイルに追加するだけ

Just add [5.1] to the code below in the migration file.

前 before
class CreateFriendlyIdSlugs < ActiveRecord::Migration
後 after
class CreateFriendlyIdSlugs < ActiveRecord::Migration[5.1]

参考 reference

1
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
1
0