Displaying 1 result from an estimated 1 matches for "doctors_specialti".
Did you mean:
doctors_specialties
2006 May 08
8
enforcing special behavior of child rows in HABTM
Hi,
I have a scenario where a doctor can have one or more specialties.
For each doctor, one and only one of her specialties can be designated
as primary.
So I have tables called doctors, specialties, and doctors_specialties,
the last of which has a boolean is_primary column.
The doctor model class specifies that:
has_and_belongs_to_many :specialties
I want to enforce, at the lowest possible level, the constraint that
a doctor can only have one primary specialty.
So, whenever a member of the association is added o...