“没有路线匹配[POST]”将link_to更改为button_to时 [英] "No route matches [POST]" when changing link_to to button_to
本文介绍了“没有路线匹配[POST]”将link_to更改为button_to时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码:
<%= link_to "New User", new_user_path, :class => "button" %><br />
工作正常,但当我将其更改为时,
which works fine, but when I change it to,
<%= button_to "New User", new_user_path, :class => "button" %><br />
我收到此错误
没有路线匹配[POST]/ users / new
No route matches [POST] "/users/new"
任何帮助都将不胜感激。
Any help at all will be appreciated.
推荐答案
耶稣罗德里格兹对POST和GET是正确的,但如果你真的需要按钮,你可以简单地覆盖默认方法:
Jesus Rodriguez is right about POST and GET, but if you really need the button you can simply override the default method:
<%= button_to "New User", new_user_path, :class => "button", :method => :get %>
这篇关于“没有路线匹配[POST]”将link_to更改为button_to时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文