开发者

Why does "link_to" work but not "button_to"

开发者 https://www.devze.com 2023-03-29 14:01 出处:网络
Why would this work? <%= link_to \"New Item\", new_site_care_path开发者_运维知识库, {:class => \"button_bottom\"} %>

Why would this work?

<%= link_to "New Item", new_site_care_path开发者_运维知识库, {:class => "button_bottom"} %>

And this (the only change is from link_to to button_to)...

<%= button_to "New Item", :url => new_site_care_path, {:class => "button_bottom"} %>

...produces:

No route matches "/site_cares/new"

UPDATE - ROUTE INFO - route file:

resources :site_cares, :except => :show

rake routes:

new_site_care GET /site_cares/new(.:format) {:action=>"new", :controller=>"site_cares"}


I think that button_to uses post by default, my ROR route skills are a bit rusty but I think the route you've shown uses GET.

There's further info in this question - Button_to in Ruby on Rails bad route

0

精彩评论

暂无评论...
验证码 换一张
取 消