Skip to content

Instantly share code, notes, and snippets.

@gangelo
Created July 8, 2014 01:57
Show Gist options
  • Select an option

  • Save gangelo/240d7624ba941caccd0e to your computer and use it in GitHub Desktop.

Select an option

Save gangelo/240d7624ba941caccd0e to your computer and use it in GitHub Desktop.
Thinkful Wikiful "/signup" postback routes to "/users"
Description:
When signing up as a new user, in "/signup," the "Create User" button will postback to "/users." Not that big a deal, until the submitted form fails validation, in which case the postback url will be "/users." I don't like going to "/signup," only to see "/users" if my form fails validation.
The following is what I did to remedy this, seems simple, but am not sure if there is a "better" way? Suggestions?
<%
# Note: url: signup_path # in routes.rb => post 'signup', to: 'users#create'
%>
<%= form_for @user, url: signup_path, html:{ role: "form"} do |f| %>
<%
# ...
%>
<% end %>
Rails.application.routes.draw do
# ...
# resources :users
get 'signup', to: 'users#new', as: 'signup'
post 'signup', to: 'users#create'
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment