我已經遇到了使用link_to的ror問題。在link_to參數中指定我的「method」=>「post」之後,爲什麼我的鏈接使用GET方法和我的button_to使用POST方法?Button_to使用POST Link_to使用GET,爲什麼? ROR
查看:
<%= button_to "pdf", :action => 'getquote' %>
<%= link_to 'pdf', {:controller => 'inventories', :action => 'getquote', :method => :post } %>
控制器的方法:
def getquote
@cart = find_cart
respond_to do |format|
format.pdf
end
end
端子輸出(按鈕/鏈接,分別爲):
Processing InventoriesController#getquote (for 127.0.0.1 at 2010-01-30 01:38:02) [POST]
Parameters: {"action"=>"getquote", "authenticity_token"=>"D2cwnHyTHgomdUM3wXBBXlOe4NQLmv1Srn0paLbExpQ=", "controller"=>"inventories"}
Processing InventoriesController#show (for 127.0.0.1 at 2010-01-30 01:39:07) [GET]
Parameters: {"method"=>"post", "action"=>"show", "id"=>"getquote", "controller"=>"inventories"}
我與ROR 3.0.17有同樣的問題(或18或19,不記得)。我做了這種標記,就像這個「新風格」,它在大多數頁面上工作,除了一個特定的頁面。電話是完全一樣的,我不知道什麼是錯的。另外螢火蟲顯示鏈接有2個數據參數:數據確認和數據方法。這應該是正確的? – 2012-09-05 19:52:54