Quick question with restful_authentication and validations

Hi everyone,

I'm using restful_authentication for my app - using Rails 2.0.2. I have things configured properly, and I'm using the "shortcut" named route of signup in my routes.rb like so:

map.signup "/signup", :controller => "users", :action => "new"

My /views/users/new.html.erb file has the form set up like this (unchanged from restful_authentication):

<% form_for :user, :url => users_path do |f| -%> <p>   <label for="login">Username</label><br/>   <%= f.text_field :login %> <%= error_message_on :user, :login, "&uarr; Username", " is required"%> </p>

<p>   <label for="email">Email</label><br/>   <%= f.text_field :email %> <%= error_message_on :user, :email, "A valid email address", " is required" -%> </p>

<p>   <label for="password">Password</label><br/>   <%= f.password_field :password %><br />   <%= error_message_on :user, :password, "A password is required" -%> </p>

<p>   <label for="password_confirmation">Confirm Password</label><br/>   <%= f.password_field :password_confirmation %><br />   <%= error_message_on :user, :password_confirmation, "Passwords must match" -%> </p>

<p><%= submit_tag 'Sign up' %></p> <% end -%>

Wayne M wrote:

Everything works, but there's a stylistic problem - To go to the signup page, the user goes to http://myapp/signup. If validation fails, though, when the page reloads to show validation errors, the address bar reads http://myapp/users, and if the user accidently hits Return/Enter it will give an error because there is no index action in the UsersController (nor do I want one - UsersController is *only* going to deal with signing up new users). Is there any way to make it stay as http://myapp/signup? I've tried changing the :url parameter of the form to signup_url, but this doesn't work because it just reloads the form without actually invoking the create method (which makes sense because the signup route points to the new action, not to create).

The URLs and process flow in your web app are handled by the routes.rb file and the controllers. In this case, you have the route defined, you just need to make sure the controller is using it consistently. I have a basic restful_authentication web app and this is the "create" method