RailsCasts Pro episodes are now free!

Learn more or hide this

pablosalgadom's Profile

GitHub User: pablosalgadom

Comments by

Avatar

I would recommend to override the should_generate_new_friendly_id? method, because it will only change the slug when ONLY needs to do it.

class Post < ActiveRecord::Base
  extend FriendlyId
  friendly_id :title, :use => :slugged

  def should_generate_new_friendly_id?
    title_changed?
  end
end