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