私のモデルで次のIDにリダイレクトするにはどうすればいいですか? おかげRailsで次のIDにリダイレクト
def update
@pedido = Pedido.find(params[:id])
if @pedido.update(processado: 1)
redirect_to "/pedidos/" + #{NextId}
#redirect_to root_path
else
format.html { render action: "edit" }
format.json { render json: @pedido.errors, status: :unprocessable_entity }
end
end
モデル 'Pedido'が' id'か(私はそれだと思う) 'created_at'によってソートされている場合、あなただけのNEXT_ID'のような何かをする必要があり= Pedido.where( "id>?"、@ pedido.id).first.id' – fanta
この作品は、大変ありがとうございました –