Hey folks,
for those of you interested in the new :joins => :associations features, can you please take a look at this patch:
http://dev.rubyonrails.org/ticket/10061
Rather than futzing around with ":joins => :associations gets loaded like :include does only we discard the included records" and having to pepper that logic throughout AciveRecord, this patch does something simpler and more consistent:
It changes add_joins!() to turn all non-string :joins arguments into a list of inner joins based on the [:associations, :you, :supply].
No other hidden magic, normal :joins semantics apply:
Swimmers.find(:all, :select => 'distinct swimmers.*', :joins => :goggles)
is the same as:
Swimmers.find(:all, :select => 'distinct swimmers.*', :joins => 'inner join goggles on goggles.swimmer_id = swimmers.id')
And the following behaves as one would expect:
Swimmers.find(:all, :include => :goggles, :joins => :noseplugs, :conditions => ['noseplugs.color = ?', 'red']) # load all swimmers and their goggles, as long as they have a red noseplug.
What I'm looking for is comments that "yeah, that's how it should be working" before I work through the tests that originally came with changeset 8054 (they assume :join => :stuff should behave like :include rather than like :join).
I have no idea what I'll do if it turns into an angry-dance-off between the "Includys" and the "Joinys".
Thanks for taking the time to look at this. Trevor