我已经遇到了使用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