Ajit
1
Hi
I have a table named “appointments” and it has a field “patient_id”.
And i have “patients” table as well, with all the patient’s personal
info
now i want to display all the appointments for today with patients
details. E.g
Name Phone Email Appointment
Time
ABC 123 [email protected] 01/08/2007 12:30
PM
I have appointments Controller, helper, model but nothing patient so
far.
Please advice
thanks
Ajit
Ajit
2
A patient has many appointments. An appointment belongs to patient.
Appointment.patient.first_name.
It’s really about that easy.
Ajit
3
On Aug 1, 2007, at 7:13 PM, Robert W. wrote:
info
I have appointments Controller, helper, model but nothing patient so
far.
Please advice
thanks
Ajit
Something in your controller like:
@appointments = Appointment.scheduled_for(Date.today)
and in your model
class Appointment
def self.scheduled_for(day)
find(:all, :include => :patient,
:conditions => { :appointment_time =>
day.to_time…day.to_time.tomorrow },
:order => ‘appointments.appointment_time, patients.last_name’)
end
end
-Rob
Rob B. http://agileconsultingllc.com
[email protected]