Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:48:45+00:00 2026-06-17T20:48:45+00:00

Using a name as key, how do we validate the name when registering by

  • 0

Using a name as key, how do we validate the name when registering by ignoring case while still remembering the case when displaying?

In config/initializers/devise.rb, setting config.case_insensitive_keys = [ :name ] seems to lowercase the entire name before registering.

Example: some dude names himself TheFourthMusketeer.

  • The views will display TheFourthMusketeer, not thefourthmusketeer
  • No new user can register under, say, tHEfourthMUSKETEER
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:48:47+00:00Added an answer on June 17, 2026 at 8:48 pm

    What you might try is to not set :name as case insensitive, which will properly save the case-sensitive name in the database:

    config.case_insensitive_keys = []
    

    Then, override the find_first_by_auth_conditions class method on User to find the user by their name. Note that this code will vary depending on the database (below is using Postgres):

    def self.find_first_by_auth_conditions(warden_conditions)
      conditions = warden_conditions.dup
      if login = conditions.delete(:login)
        where(conditions).where("lower(name) = ?", login.downcase).first
      else
        where(conditions).first
      end
    end
    

    Doing this, a User.find_for_authentication(login: 'thefourthmusketeer') will properly return the record with a name of “TheFourthMusketeer”.

    See https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address for an explanation of overriding this method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While in search of trying to implement unique key validations for my db using
I have a using statement defined like this in codebehind: using Name = Extremely.Long.And.Unwieldy.Namespace
Using class name I am firing a click event in jquery. Class names are
I need to Find Previous month name using Calender or any classes that in
I want to get the class name using jQuery And if it has an
How can I in change the table name using a query statement? I used
When we define routes in routes.rb using the name like map.some_link .We can use
How can I retrieve the XML source file name using XSL 1.0 code?
Code to create new form instance of a closed form using form name I
I'm trying to access to our appliance machine name using: http://<APPLIANCE-HOSTNAME>:19900/xmlfeed (of course replacing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.