Ok, that’s not the best subject line, but I couldn’t think of a
concise way to describe what I’m trying to do.
I’ve got two models. Grouping simply contains an id and a few other
attributes (e.g. rating). A grouping can contain many elements which
are stored the Element model.
A set of elements is tied together by a grouping_id. An element can
be one of several types of objects. I’m doing this with polymorphic
I need a way to ensure that a grouping is unique. That is, there
should not be two grouping_ids containing the exact same elements.
The closest analogy I can think of is a composite primary key.
Except, this is across multiple rows (instead of columns) and uses
polymorphic association types and ids.
Can this be easily done with Rails and ActiveRecord?