Ada*_*NYC 17 routing routes ruby-on-rails
我有以下按钮,我将其覆盖以生成GET请求:
= button_to "Tutor", {:controller => "appointments", :action => "new",
:listing_id => @listing.id} , :method => :get
Run Code Online (Sandbox Code Playgroud)
但是,我仍然得到一个带有额外参数的POST请求:方法:
Processing by AppointmentsController#new as HTML
Parameters: {"authenticity_token"=>"AWkL", "listing_id"=>"2", "method"=>"get"}
Run Code Online (Sandbox Code Playgroud)
我的路线档案,我有:
resources :appointments
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
谢谢.
Doc*_*rRu 40
只需使用方法:和:get
button_to "New User", new_user_path, method: :get
Run Code Online (Sandbox Code Playgroud)
Ser*_*sev 11
按钮不应该发送GET请求.
你应该用一个link_to代替.如果您希望它看起来像一个按钮,请应用一些CSS.这是一篇很好的文章:http://coding.smashingmagazine.com/2009/11/18/designing-css-buttons-techniques-and-resources/
| 归档时间: |
|
| 查看次数: |
13878 次 |
| 最近记录: |