1

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"}
Jay
  • 6,206
  • 11
  • 48
  • 82

1 Answers1

2

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

Community
  • 1
  • 1
ipr101
  • 24,096
  • 8
  • 59
  • 61
  • probably violate sensibilities of some of the folks in the rails community, but created my own "link_to" button with a div. I don't think users notice that buttons are for posts and links are used elsewhere do you? ps... glad i got to put you over the 2000 mark... not that u notice that kind of thing :=] – Jay Aug 19 '11 at 16:52
  • @Jay -Thanks for pushing me over the 2000 barrier :) Think you're definitely doing the right thing with the button! – ipr101 Aug 19 '11 at 19:37