Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"rails generate friendly_id" does not produce correct migration syntax for Rails 5.1 #817

Closed
chrickso opened this issue Jun 25, 2017 · 5 comments
Labels

Comments

@chrickso
Copy link

Hi. I'm new to Rails so apologies if this is something on my end done wrong but I am following a tutorial that has me installing friendly_id and after following the friendly_id documentation instructions of running "rails generate friendly_id", the db:migrate is failing with the following message:

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

  class CreateFriendlyIdSlugs < ActiveRecord::Migration[4.2]

i got it working by adding "[5.1]" after the ActiveRecord::Migration in the migration file and rerunning db:migrate. I assume this is due to something new in Rails 5.1 because my instructor was running 5.0 and didn't have any issues.

class CreateFriendlyIdSlugs < ActiveRecord::Migration[5.1]
  def change
    create_table :friendly_id_slugs do |t|
      t.string   :slug,           :null => false
      t.integer  :sluggable_id,   :null => false
      t.string   :sluggable_type, :limit => 50
      t.string   :scope
      t.datetime :created_at
    end
    add_index :friendly_id_slugs, :sluggable_id
    add_index :friendly_id_slugs, [:slug, :sluggable_type]
    add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], :unique => true
    add_index :friendly_id_slugs, :sluggable_type
  end
end

hope this helps. thanks!

@lazyatom
Copy link
Contributor

This is addressed in #816, I hope

@superkunn
Copy link

Than Q very much

@olivierlacan
Copy link
Contributor

@lazyatom @chrickso Can this issue be closed?

@lazyatom
Copy link
Contributor

lazyatom commented Oct 4, 2019

Yes, it was fixed in #858. Thanks!

@stale
Copy link

stale bot commented Dec 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 11, 2019
@stale stale bot closed this as completed Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants