ログイン状態でも他のユーザーの編集が出来てしまう状態をログインしていてユーザーIDが一致していないと編集出来ない状態にする。
controller.rb
def edit
@item = Item.find(params[:id])
redirect_to root_path unless current_user.id == @item.user_id
end
More than 1 year has 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