How to pass params in redirect_to

2.5k Views Asked by At

I'm getting an error when trying to redirect to the users profile when erasing a tag from a photo. What am I doing wrong? Im getting stuck with this! Thanks!

def destroy
@photo = Photo.find(params[:id])
if @photo.destroy
redirect_to :controller => 'users', :action => 'show', id: @user_id
end
end
2

There are 2 best solutions below

2
On BEST ANSWER

@user_id is missing in your action, if you are using devise, you can pass id of the logged in user by

redirect_to :controller => 'users', :action => 'show', id: current_user.id
3
On

Try redirect_to user_path(@user_id)

Type rake -T in rails console to see all your routes