I am using Friendly_id gem to create Clean URL and it work just fine but instead of having a URL like this http://localhost:3000/profile/jack-sparo
I want a URL like this http://localhost:3000/profile/1/jack-sparo
where 1
is the user_id
, so how can I do it?
this is my config/routes
get "profiles/show"
get '/profile/:id' => 'profiles#show', :as => :profile
get 'profiles' => 'profiles#index'
and this is my Profile controller
def show
@user= User.find_by_slug(params[:id])
if @user
@posts= Post.all
render action: :show
else
render file: 'public/404', status: 404, formats: [:html]
end
end