我想确保用户可以看到他们的个人资料,但看不到其他人的个人资料。我认为这会起作用,但事实并非如此。
def show
if current_user
if current_user.id != User.find(params[:id])
@user = User.find(params[:id])
@title = @user.name
end if
else
redirect_to root_path
end
end
知道我做错了什么吗?