I've been following the Railscast tutorial on how to implement friendly_id and for some reason my URL's doesn't change after I update my attributes.
Say I registered a user with :fullname 'John Doe' it creates the slug /john-doe successfully. However if I update my name to 'Test user' the url is still /john-doe
My current setup is this:
users_controller
def show
@user = User.friendly.find(params[:id])
end
model - user.rb
extend FriendlyId
friendly_id :fullname, use: [:slugged, :history]
I've also migrated
class AddSlugsToUsers < ActiveRecord::Migration
def change
add_column :users, :slug, :string
add_index :users, :slug, unique: true
end
end
so that is working. Also installed
rails generate friendly_id
and done:
User.find_each(&:save)
in rails c
What am I doing wrong?