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| -%>
Username
<%= f.text_field :login %> <%= error_message_on :user, :login,
"↑ Username", " is required"%>
Email
<%= f.text_field :email %> <%= error_message_on :user, :email, "A
valid email address", " is required" -%>
Password
<%= f.password_field :password %>
<%= error_message_on :user, :password, "A password is required" -%>
Confirm Password
<%= f.password_field :password_confirmation %>
<%= error_message_on :user, :password_confirmation, "Passwords must
match" -%>
<%= submit_tag 'Sign up' %>
<% end -%>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).
I’ve done a Google search but no avail. I’m still a little new to
Rails and, honestly, to RESTful concepts as well but I am trying to
learn. Any help solving this problem would be appreciated.
Also, does anyone know how to override the error_message_on method so
it won’t return a DIV tag? I want my validations to appear next to
the textbox in question, not below them. Changing the CSS property of
the formError DIV to display: inline doesn’t do anything - the new DIV
is still placed below the offending textbox. This isn’t really a big
deal, as I can modify the layout to accommodate it. The address bar
issue is a bigger problem because it’s user-facing and confusing.