mongoid/mongoid — pull request #2944 by voldy (2013-04-04 23:29:16+00:00)
Title: Fixed case insensitive uniqueness validation for localized fields

Localized fields should be validated separately for each localization because the value should be unique in each locale.

For example, we have a document with localized attribute:

{ description: { "en" => "Car", "de" => "Auto" } }

We want to add a new document:

{ description: { "en" => "Motorbike", "de" => "Auto" } }

The description hash is different but we have the same value for "de" locale. To solve this issue I implemented uniqueness validation for licalized fields using $or selection:

validatable.or(
{ "description.en" => "English" }, { "description.de" => "German" }
)

case_sensitive flag was also fixed.