开发者

rails 3 using devise for authentication

I am using Devise in my Rails 3 application for authentication.

My requirement is 开发者_如何学Cto use Username to login rather than email.

So I modified the config/initializers/devise.rb file as below

config.authentication_keys = [ :username ]

Modified the registraion page to take username, email, password during registration. Also modified signin, signup views to include username.

My Issue:

When I click on Forgot password, it shows me field to enter email. After I enter 'email' and click on button 'Send me reset password instructions'.

It throws an error Username can't be blank.

Where do I make changes to fix this?


I would presume that authentication_keys set :username as a required field.

Try editing app/views/devise/passwords/new.html.erb, and replacing:

<%= f.label :email %>
<br />
<%= f.text_field :email %>

with:

<%= f.label :username %>
<br />
<%= f.text_field :username %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜