views:

27

answers:

1

I use authlogic in my RoR app. For login, I use email and password like this:

<% form_for @user_session, :url => user_session_path do |f| %>
  <%= f.error_messages %>
  <%= f.label :email %><br />
  <%= f.text_field :email %><br />
  <br />
  <%= f.label :password %><br />
  <%= f.password_field :password %><br />
  <br />
  <%= f.check_box :remember_me %><%= f.label :remember_me %><br />
  <br />
  <%= f.submit "Login" %>
<% end %>

This was working fine, but I've just added a 'username' field to my user model, and now I'm getting this error (on the <%= f.text_field :email %> line):

 NoMethodError in User_sessions#new
undefined method `email' for #<UserSession: no credentials provided>

I'm assuming that this error is occurring because I now have a username field? How can I have a username field, but not use it for the login?

+1  A: 

I believe that Authlogic automatically uses the username field if it exists. If you are not using the username field for authentication then the simplest solution to your answer would be to rename the username column.

aaronmase