开发者

Using authlogic, login using email and password was working fine. I just added a username field to my User model, and now login doesn't work

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开发者_如何学JAVA 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜