help with validates _uniqueness_of for a has_many table

i have a list of COMPOUNDS (combinations) that have any number of
COMPOUND_MATERIALS of which both are ITEMS. (this is for a video game
item database)

i want to validate that the compounds are unique by validating it's
combination of compound_materials does not already exist (a compound can
have multiple combinations of materials)

my tables:

ITEMS
id
name
...

COMPOUNDS (has many compound materials)
id
item_id

COMPOUND_MATERIALS
id
compound_id
item_id

so how would i use this in my model?

validates_uniqueness_of :item_id, scope =>
['compound_materials.item_id', ....

something like that but i'm confused because a compound can have any
number of compound_materials so I'm not sure how to write that out.

thanks.