Has_many relationship - specify how quantity (how many)

Hi,

Is there any way to specify a a validation rule or something for the
"has_many’ relationship so that it would count the related objects?

For e.g. I want my Foo object to have maximum of 5 Bar objects in
has_many relationship.

M.

I suppose you could write a custom validator to ensure that no more than
5
child objects exist.

On Sun, Jul 5, 2009 at 5:12 PM, Michal B. <

validates :bar_limit

def bar_limit

end

-eric

On Jul 5, 2:12 pm, Michal B. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs