Is it possible to perform eager loading over multiple relationships?
Here''s a brief look at the relevant data models:
Project has_many Album has_many Song belongs_to Label
I feel all happy for properly modeled 3NF data but because of the way
this is set up I have this method in Album to collect the Labels from
its songs:
def labels
songs.inject(Set.new) { |l, song| l << song.label }
end
and a similar one in Project. Unfortunately all this requires
loading a bunch of data just to get to my information and is hella
slow. Is there a way to specify eager loading of associations''
associations? Something like:
Project.find(:all, :include => :albums.songs.labels)
Or should I just make Project#labels and Album#labels find_by_sql
methods and be done with it?
Thanks,
George
--
George Hotelling GPG: 0x8175D485 ]
http://george.hotelling.net ]
_ _ _ ___ _ _ _/
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails