I have a collection that has a username as a field. The Model defines this field to be unique. However I was able to insert a duplicate value in the database.
class Profile
include Mongoid::Document
include Mongoid::Paperclip
field :username
index({ username: 1 } , { unique: true })
end
The Collection however has 2 usernames that are the same
{ "_id" : ObjectId( "50b3b323421aa95da6000004" ),
"username" : "marceloreuse" }
{ "_id" : ObjectId( "50b3b567421aa93d84000002" ),
"username" : "marceloreuse" }
What went wrong here?