I''ve got a tricky (at least for me) model association I need to
establish. Here are the two tables
Appointment
id, name, start(datetime), stop(datetime)
1, apt1, 1/4/2011 14:00, 1/4/2011 14:30
Schedule
id, name, start(datetime), stop(datetime)
1, sch1, 1/4/2011 08:00, 1/4/2011 17:00
I need to associate a schedule with an appointment. So each
appointment will have_one schedule. The assocation get''s created by
virtue of the start/stop of the appointment being in between the start/
stop of a schedule.
This sql will return the record
select *
from apts a
inner join schedules s on s.start <= a.start and s.stop >= a.stop
So what do I do?
class Apt < ActiveRecord::Base
has_one :schedule, something here
end
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.