Forum: Ruby on Rails Day.find_all_with_appointments - INNER JOIN

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0091f92762685860109bbcb02edfdf27?d=identicon&s=25 Alain Ravet (Guest)
on 2006-01-10 18:51
(Received via mailing list)
Hi list,


Is there a better/simpler way to code an inner join, than the 4 lines
below:

     class Day < Foo

         def self.find_all_with_appointments (*args)
             find  :all,
             {  :select => 'distinct foos.*',
             	:joins => 'INNER JOIN appointments ON days.appointment_id
= foos.id'
             }.merge (extract_options_from_args!(args))

         end
         has_many    :results  , :class_name => "Result", :foreign_key
=> "event_id"
     end


:include doesn't help here, as it produces an outer join.


Alain
This topic is locked and can not be replied to.