ERRORて属性を更新しようとしているとき:Noルートマッチ[GET] "/予約/:ID /%の3E:フォーマット"のRails:経路エラーのlink_to
私は時にクリック "のリンクの属性を更新したいですlink_to」..
<%= link_to 'Cancel', '/bookings/:id/(.:format)' %>
routes.rbを
put '/bookings/:id/(.:format)' => "bookings#tocancel"
patch '/bookings/:id/(.:format)' => "bookings#tocancel"
コントローラ
def tocancel
@booking = Booking.find(params[:id])
@booking.update_attribute(:status, "cancel")
respond_to do |format|
format.html { redirect_to @booking, notice: 'Booking was successfully cancelled.' }
format.json { render :show, status: :ok, location: @booking }
端
URL形式をlink_toに渡すことはありません。ヘルパーメソッドbookings_pathを使用して、@ bookingオブジェクトを渡すことができます。それについての(優秀な)ドキュメントを読んでください:http://guides.rubyonrails.org/routing.html – MrWillihog
''% '=' link_to 'キャンセル'、 'complete_url/bookingings/pass_id_value_here'% ''id:場所。 –
エラー:getprojecting_path(booking)%>リンク:[GET] "/予約/ 36/tocancel"に一致するルートがありません –