I have a model, Property, that has_many_polymorphs. The associated join
table (labellings) has fields:
id (simple record id),
It's basically the same system used with acts_as_taggable, except that
Property objects are a tree instead of a simple list (which doesn't have
any bearing on this problem, i think).
If i add a property to an object then a join table entry is created. If
i add it again, i now have the object labelled twice with the same
property, which i don't want. I could say
object.properties << prop unless object.properties.include? prop
But that's a bit cumbersome.
Ideally i'd use validates_uniqueness_of - i know that i can do this for
a combo of two values, with, eg
validates_uniqueness_of :property_id, :scope => :labellable_id
But i don't know how to do it for three fields. I tried this:
validates_uniqueness_of :property_id, :scope => [:labellable_id,
but got this exception when i tested it:
ActiveRecord::RecordInvalid: Validation failed: Property has already
Anyone know how to do this?