0

I want to update slug column when screen_name is updated, so I write like this.

class User < ActiveRecord::Base
  extend FriendlyId
  friendly_id :screen_name, use: :slugged

  def should_generate_new_friendly_id?
    slug.blank? || screen_name_changed?
  end
end

But it doesn't work. What should I do to make it work? I'm using rails 4.0.2 and friendly_id 5.0.2.

And slug is properly generated when a user is created.

ironsand
  • 14,329
  • 17
  • 83
  • 176

1 Answers1

0

I was going to write as a comment, but it will be clearer here

We have the exact same code working in one of our apps:

#Slug
def should_generate_new_friendly_id?
    slug.blank? || title_changed?
end

The only thing I would suggest is to post your logs for when you update a user?

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • 1
    Sorry, when I tried to recreate the problem, it disappeared somehow. Thanks for your answer anyway. – ironsand Feb 27 '14 at 11:12