Colin Thanks for your answer. The student/class thing was just an example - the actual stuff I'd be building has nothing to do with students and classes it was just the easiest thing that came to me.
You can do a validation on a total number of related records? I did not know that. On Wed, Jul 1, 2015 at 8:59 AM, Colin Law <[email protected]> wrote: > On 1 July 2015 at 16:51, John Lahr <[email protected]> wrote: > > Can you limit the number of related records a given parent record has? > > > > Example. Class/Student relatoinship. A Class has_many students but I > want > > to limit the size of a class to a max 30 (of course minimum or exact > numbers > > would hopefully work the same way?) > > There may be a better way but I would just use a validation that > prevents further students being added to the class when the limit is > released. > > By the way, can a student be in more than one class? If so then you > need has and belongs to many or (which I prefer) has many through. > > Colin > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/rubyonrails-talk/aadce5fd-8e2a-4596-9b68-b88c952354a2%40googlegroups.com > . > > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/rubyonrails-talk/IvBfZMAFC7g/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLu3J0a8d0p8dEsmcmaQYwPMYZaMu%2BQ2wCCG3A8iOzbehw%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAEBjNa2e7-r8Uq0rrta9N9%2Bx0BROTXBJEq4UE9jgNWzv4H_g9Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

