-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Seller include Mongoid::Document field :seller_id, :type => Integer field :name, :type => String embeds_many :seller_products key :seller_id end class SellerProduct include Mongoid::Document field :product_id, :type => Integer key :product_id embedded_in :seller, :inverse_of => :seller_products validates_uniqueness_of :product_id end
`
Validates_uniqueness_of doesnt work if i set my key to be :product_id
Uniqueness validator criteria becomes:
<Mongoid::Criteria
selector: {:product_id=>10, :_id=>{"$ne"=>"10"}},
options: {},
class: SellerProduct,
embedded: true>
When i remove the key it works
<Mongoid::Criteria
selector: {:product_id=>1, :_id=>{"$ne"=>BSON::ObjectId('4eaf0733a5d09fb9ef000006')}},
options: {},
class: SellerProduct,
embedded: true>