ruby-on-railsruby-on-rails-3deviseruby-on-rails-3.2usernametoken

Javascript issue adding username login instead of email for Devise in Rails


I followed the instructions for adding a username login instead of email (actually in addition to email) for Devise. Problem is when I go to actually sign in, there's a Javascript mechanism to make the login field red when a non-email address is entered. Then when you click the sign in button, there's Javascript to prevent you from signing in and presents a black bubble stating, "Please enter an email address".

Did I do something wrong? Are those Devise instructions out of date? How do I allow users to enter usernames instead of email addresses to login? I'm using the latest Devise and Rails (v3.2.8).


Solution

  • I think you did something wrong. I implemented a login similar to what you're describing recently and it worked just fine.

    It sounds like you need to edit your devise templates. Have you generated them already? If so, you need to change the field types to text fields wherever you have an email field and make sure you're referencing 'login' instead of email.

    The "Update your views" section of that link explains how to do that.