Reputation: 1
I have a model with doctor and patients with associations:
Class doctor has_may :patients Class patient belongs_to :doctor
I need to make limit of free payment patients and other limit for payed patients. Who can i it?
For now my doctor has no limit patients. It's not right.
Upvotes: -1
Views: 61
Reputation: 579
You can do it using length validation like this:
class Doctor
has_many :patients
validates_length_of :patients, maximum: 10
end
class Patient
belongs_to :doctor
validates_associated :doctor
end
Check this answer from @jstejada.
Upvotes: 1