Reputation: 51
I'm using the friendly_id
gem for the first time in a Rails 4.1.6 project, and trying to use finders
, history
, and sluggable
together, but history
doesn't seem to be working.
I set it up following the railscast tutorial and added finders
in to my Model's friendly_id
definition:
extend FriendlyId
friendly_id :title, use: [:slugged, :finders, :history]
def should_generate_new_friendly_id?
slug.blank? || title_changed?
end
As well as adding in the method from the friendly_id.rb
initialiser to allow for making a new slug every time the title attribute changes
I've added the slug to the database, migrated, ran rails g friendly_id
and saved each of the model to create their slug and friendly_id_slug, just not sure why history
won't work!
Upvotes: 2
Views: 908
Reputation: 51
I've figured it out, history needs to be defined before finders in the Model
friendly_id :title, use: [:slugged, :history, :finders]
Everything's working now :)
Upvotes: 3