Hello there, newbie speaking
Let’s say I have:
class Office
has_many :holidays #(just a list of dates when the office is closed)
has_many :doctors #doctors who work in the office
end
class Doctor
belongs_to :office
has_many :holidays #(additional dates when this doctor is not
available)
end
class Holiday (has a office_id, doctor_id and a date field)
end
From the app standpoint I would like to be able to allow the
administrator to set office-wide closed dates, but to allow an
individual doctor to augment that list with additional dates he/she
won’t be available in.
What is the best/most elegant way to retrieve the merged list of
holidays for a doctor?
I know I could retrieve the Office holidays in the doctor model and
merge it with the Doctor’s holidays, but I was wondering if there was a
more activerecord/rails-specific pattern that I might be missing to
allow one DB query with the ‘inherited’ holidays from the Office…
Thanks
Enrico.