-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Model include Mongoid::Document include Mongoid::Timestamps field :foreign_identity index :foreign_identity, :unique => true validates :foreign_identity, :uniqueness => true end
Model.create! :foreign_identity => '' Model.create! :foreign_identity => '' #uniqueness validation failed Model.count #reports "2" Model.where(:foreign_identity => '').first #returns "nil"
This happens because while creating foreign_identity is given value "", however where method queries for value nil for foreign_identity and so doesn't find any. Same with validation.
P.S. It seem to only happen if attribute name is foreign_identity.