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 179317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:23:09+00:00 2026-05-11T14:23:09+00:00

Here is the model (I am using SQLLite3): class School < ActiveRecord::Base validates_uniqueness_of :name

  • 0

Here is the model (I am using SQLLite3):

class School < ActiveRecord::Base    validates_uniqueness_of :name  end 

For example, after I add ‘Yale’, I cannot add ‘Yale’ but can add ‘yale.’ How can I make the validation case insensitive?

EDIT: Found it – Active Record Validations

  • 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. 2026-05-11T14:23:09+00:00Added an answer on May 11, 2026 at 2:23 pm

    validates_uniqueness_of :name, :case_sensitive => false does the trick, but you should keep in mind that validates_uniqueness_of does not guarantee uniqueness if you have multiple servers/server processes (e.g. running Phusion Passenger, multiple Mongrels, etc) or a multi-threaded server. That’s because you might get this sequence of events (the order is important):

    1. Process A gets a request to create a new user with the name ‘foo’
    2. Process B does the same thing
    3. Process A validates the uniqueness of ‘foo’ by asking the DB if that name exists yet and the DB says the name doesn’t exist yet.
    4. Process B does the same thing and gets the same response
    5. Process A submits the insert statement for the new record and succeeds
    6. If you have a database constraint requiring uniqueness for that field, Process B will submit the insert statement for the new record and fail with a ugly server exception that comes back from the SQL adapter. If you do not have a database constraint, the insert will succeed and you now have two rows with ‘foo’ as the name.

    See also ‘Concurrency and integrity’ in the validates_uniqueness_of Rails documentation.

    From Ruby on Rails 3rd Edition:

    …despite its name, validates_uniqueness_of doesn’t really guarantee that column values will be unique. All it can do is verify that no column has the same value as that in the record being validated at the time the validation is performed. It’s possible for two records to be created at the same time, each with the same value for a column that should be unique, and for both records to pass validation. The most reliable way to enforce uniqueness is with a database-level constraint.’

    See also this programmer’s experience with validates_uniqueness_of.

    One way this commonly happens is accidental double-submissions from a web page when creating a new account. This is a hard one to solve because what the user will get back is the second (ugly) error and it will make them think their registration failed, when in reality it succeeded. The best way I’ve found to prevent this is just to use javascript to try to prevent double-submission.

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

Sidebar

Ask A Question

Stats

  • Questions 135k
  • Answers 135k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I (sort of) figured it out. I needed to add… May 12, 2026 at 7:04 am
  • Editorial Team
    Editorial Team added an answer Consider trying to install this by copying some files around.… May 12, 2026 at 7:04 am
  • Editorial Team
    Editorial Team added an answer You can store some information in image metadata. In fact… May 12, 2026 at 7:04 am

Related Questions

I am playing around with getting some basic stuff to work in Python before
I am using ADO.Net DataServices to expose an Entity Data Model to Silverlight. The
My DBAs have informed me that one of my applications is really bogging down
I am using the ASP.NET Client-Side ajax control toolkit in my asp.net MVC application.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.