I'm using Authlogic for user authentication, and I'm trying to set up
the login screen (I'm having the same problem with the registration and
other forms, though, but logging in is a nice simple example).
My problem is that the login screen can be accessed through
example.com/login just as I'd like it to be, but when there's a problem
with the form input, the url changes to example.com/user_session, which
I really don't like. If I change the "render :new" in the controller to
"redirect_to login_path" then I'm sent to the correct url, but the
rails-generated errors don't appear, and the information that had been
entered is wiped out, so I don't want to do that.
I'm using a named url for the login screen:
map.login '/login', :controller => 'user_sessions', :action => 'new'
My controller looks like:
@user_session = UserSession.new
@user_session = UserSession.new(params[:user_session])
flash[:notice] = "You are now logged in"
And a simple view, for now:
<% form_for @user_session, :url => user_session_path do |f| %>
<%= f.error_messages %>
<%= f.label :email %><br />
<%= f.text_field :email %><br />
<%= f.label :password %> - <%= link_to "Forgot Your Password?",
password_reset_path %><br />
<%= f.password_field :password %><br />
<%= f.check_box :remember_me %><%= f.label :remember_me %><br />
<%= f.submit "Login" %>
<% end %>
There must be a simple solution to this - I'm just learning rails, but
even so I feel like I'm missing something totally obvious. Can anyone
make a suggestion?