I know Rails has a one_to_many relationship, but I want to enforce that "many" is at least one object. What's the most elegant way to do this?
views:
18answers:
1
A:
Add a validation in your one model to check there are most of one many object
def validates
errors.add(:many_objects, 'You need at least one object') if many_objects.empty?
end
shingara
2010-03-11 13:54:56