-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
validates_uniqueness does not work when it's set in an embedded document. Let's say I want all report names to be unique (system-wide):
class User
embeds_one :report
end
class Report
field :name
validates_uniqueness_of :name
embedded_in :user, :inverse_of => :report
end
With the following spec:
report = Report.make(:name => "x")
Report.make_unsaved(:name => "x").should_not be_valid # Error, it is valid!
I'm not sure this is a bug, it might very well be I'm doing something wrong here. But, maybe it is a bug.