フラグがたって編集不可能になったアイテムに、ユーザーがURL直打ちでアクセスしたときに
リダイレクトさせたいです。通常のリダイレクト処理はわかるのですが、
フラグがたった場合にリダイレクトさせる処理はどう書くのか教えてください
現在はフラグが立っていないアイテムのみ@itemに入れています。
lang
1def update 2 @item = current_user.items.find_by(id: params[:id],flag: false) 3 respond_to do |format| 4 if @item.update(item_params) 5 format.html { redirect_to @item, notice: 'アイテムを編集しました。' } 6 format.json { render :show, status: :ok, location: @item } 7 else 8 format.html { render :edit } 9 format.json { render json: @item.errors, status: :unprocessable_entity } 10 end 11 end 12 end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/01/27 03:32
2015/01/27 03:34
2015/01/27 04:11
2015/01/28 23:54