I have products and categories, and a has_and_belongs_to_many relationship so that products can be in multiple categories. When adding a product, I want to ensure that the user selects at least one of the categories from the list.

How do I go about this? I'm unsure whether it's something I have to specify in the relationship itself, or if it's something I can do using validates_presence_of in some way.

Hopefully someone can point me in the right direction!