concept for foreign key

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 abc@xyz.com 01/08/2007 12:30
PM

I have appointments Controller, helper, model but nothing patient so
far.

Please advice

thanks

Ajit

A patient has many appointments. An appointment belongs to patient.
Appointment.patient.first_name.

It's really about that easy.

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 Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

thank you guys..