I am trying to use the Friendly_id gem and it works for user edit but not user show page. On the user show page it still uses the user id instead of the user_name which is the slug. I am not sure what my mistake is thank you for all the help.
routes
class User < ApplicationRecord
extend FriendlyId
friendly_id :user_name, use: :slugged
end
user_controller
def edit
@user = User.friendly.find(params[:id])
end
def show
@user = User.friendly.find(params[:id])
end
routes
Rails.application.routes.draw do
resources :users
end
Following the official document of friendly_id, i guessed that you missed this line: extend FriendlyId
class User < ApplicationRecord
extend FriendlyId
friendly_id :user_name, use: :slugged
end