我遇到了一个使用link_to的ror问题。为什么我在link_to参数中指定了"method"=>"post"后,我的链接使用GET方法而我的button_to使用POST方法?
视图:
<%= 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"}