ログイン状態でも他のユーザーの編集が出来てしまう状態をログインしていてユーザーIDが一致していないと編集出来ない状態にする。
controller.rb
def edit
@item = Item.find(params[:id])
redirect_to root_path unless current_user.id == @item.user_id
end
Go to list of users who liked
More than 3 years have passed since last update.
def edit
@item = Item.find(params[:id])
redirect_to root_path unless current_user.id == @item.user_id
end
Register as a new user and use Qiita more conveniently
Go to list of users who liked