Displaying 1 result from an estimated 1 matches for "star_tim".
Did you mean:
starttim
2006 May 27
7
How should I select rows from a join-model based on more than one association?
..., host_id, start_time. It
belongs_to :convention, :workshop, and :host.
Associations make it very easy to select by one association. If I want
to get the start_time of all workshops held on RubyConf Matz, I just
find RubyConf''s model instance and call
#convention_workshops.collect{|cw| cw.star_time} on it. But suppose we
want to select the start_time for only the workshops hosted by Matz on
RubyConf. How should we do that?
The SQL way would be:
SELECT convention_workshops.start_time
FROM convention_workshops, conventions, hosts
WHERE conventions.id=convention_workshops.convention_id...