On 1 July 2015 at 16:51, John L. [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
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.