Forum: Ruby on Rails validates_uniqueness_of on has_and_belongs_to_many

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
51f10739fd903d3b57561a15e4598954?d=identicon&s=25 M Daggett (Guest)
on 2005-12-20 20:17
(Received via mailing list)
I am trying to create a model that allows only unique assets to be
added to a category. However, they could be added again to a different
category. Finally, an asset can be shared across many categories. So
my question is how do you check the uniqueness across a join table?

This does not compile....

has_and_belongs_to_many :categories, :foreign_key => 'asset_id'
validates_uniqueness_of :data, :scope => 'asset_categories.category_id'


This topic is locked and can not be replied to.