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-+zpghU0kKgY@public.gmane.org 01/08/2007 12:30 PM I have appointments Controller, helper, model but nothing patient so far. Please advice thanks Ajit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A patient has many appointments. An appointment belongs to patient. Appointment.patient.first_name. It''s really about that easy. On Aug 1, 5:45 pm, Ajit <ajitscor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 a...-+zpghU0kKgY@public.gmane.org 01/08/2007 12:30 > PM > > I have appointments Controller, helper, model but nothing patient so > far. > > Please advice > > thanks > > Ajit--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 1, 2007, at 7:13 PM, Robert Walker wrote:> A patient has many appointments. An appointment belongs to patient. > Appointment.patient.first_name. > > It''s really about that easy. > > On Aug 1, 5:45 pm, Ajit <ajitscor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> 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 a...-+zpghU0kKgY@public.gmane.org 01/08/2007 >> 12:30 >> PM >> >> I have appointments Controller, helper, model but nothing patient so >> far. >> >> Please advice >> >> thanks >> >> AjitSomething 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-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thank you guys.. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---