-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Hi,
validates_uniqueness_of :title, :scope => where(posted_on:
is not working. Being title is a string field and posted_on is a datetime field. Actual problem is validate uniqueness of title in a day.
If found an alternate solution.
validates_uniqueness_of :title, if: -> { Ad.where(title: title, posted_on: { "$gt" => posted_on.beginning_of_day, "$lte" => posted_on.end_of_day}
).size > 0 }
Can you suggest a better solution.
- is related to
-
MONGOID-4815 Add :conditions option example to reference documentation
- Closed
- links to