I'm attempting to put some slick buttons on my rails app to serve as links. However, I'm running into an odd problem in my attempt to do so. I've attempted to add a link button as follows:
<%= button_to( "New", :action => "new", :controller => "registrations") %>
This results in a nice new button to direct my users to the sign_up page.
Here's where it gets weird: when I click on the button I am routed to http://localhost:3000/users/sign_up
and receive the following error:
No route matches [POST] "/users/sign_up"
But this simply isn't true. In fact, I can highlight the very url that brought me to that error, copy it and paste it into a new tab and it loads fine.
To be absolutely clear, here's the path from rake routes
:
new_user_registration GET /users/sign_up(.:format) registrations#new
What might be going on here?
Any thoughts are appreciated.
Your routes expecting method get where as button_to` aren't supposed to be sending GET requests, That's creating problem.
you have to do one of the following thing
1.Change button_to
to link_to
<%= link_to( "New", :action => "new", :controller => "registrations") %>
2.Add :method => :get
<%= button_to( "New", {:action => "new", :controller => "registrations"}, :method => :get) %>