0
votes

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

My requirement is to 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?

1

1 Answers

4
votes

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 %>