我正在尝试生成一个将使用 post 方法的链接
<%= link_to "guess", :action => "submit_guess", :method => "post" %>
但是当我点击那个链接时,我得到了
No route matches [GET] "/guess/submit_guess"
我正在尝试生成一个将使用 post 方法的链接
<%= link_to "guess", :action => "submit_guess", :method => "post" %>
但是当我点击那个链接时,我得到了
No route matches [GET] "/guess/submit_guess"
<%= button_to 'guess', action: 'submit_guess' %>
或者,如果您启用了 JS:
<%= link_to 'guess', action: 'submit_guess', method: :post %>
# note the symbol
(如果需要,最好先使用button_to
然后用 css 设置样式)
<%= link_to "guess", {:action => "submit_guess"}, :method => "post" %>