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...

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to