Skip to content

Instantly share code, notes, and snippets.

@ashleyvernon
Last active September 30, 2016 20:19
Show Gist options
  • Save ashleyvernon/e65f12e5cd6c054bbafc6d859a3715c9 to your computer and use it in GitHub Desktop.
Save ashleyvernon/e65f12e5cd6c054bbafc6d859a3715c9 to your computer and use it in GitHub Desktop.
Author: Scott Whitman
Author: Ashley Vernon
Documentation on button_to:
http://apidock.com/rails/ActionView/Helpers/UrlHelper/button_to
Issue:
<%= link_to "New User", new_user_path, :class => "button" %><br />
<%= button_to "New User", new_user_path, :class => "button" %><br />
Error: No route matches [POST] "/users/new"
The reason this doesn't work is because by default button_to has a default method of Post. You can overwrite it:
<%= button_to "New User", new_user_path, :class => "button", :method => :get %>
@ashleyvernon
Copy link
Author

ashleyvernon commented Sep 30, 2016

screen_shot_2016-09-30_at_12 06 19_pm_720

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment