Given a HABTM relationship, for example between Products and
Categories, is it appropriate to add a validation such as the
following?
product.rb
validates :categories, :presence => true
This works for me. If there’s not at least one associated category
then validation fails, and if there is then it passes.
However I’m wondering if it’s correct or if there might be unintended
consequences, especially because I can’t find examples of this usage
anywhere.
What do people most commonly do in this situation? I know I can write
a custom validation method, but since this seems to work…