Lance
unread,Aug 26, 2010, 1:39:31 AM8/26/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Talk
Hello all,
I've been trying out Rails 3 and can't get past this issue:
I have a simple has_many :through:
class Author < ActiveRecord::Base
has_many :author_series
has_many :series, :through => :author_series
end
class Series < ActiveRecord::Base
has_many :author_series
has_many :authors, :through => :author_series
end
In my controller I would like to eager load all of the authors:
@series = Series.includes(:authors).all
This will eager load the intermediate class, but only loads the first
author record. When I iterate the others, they are each fetched
individually (N+1).
Any help would be appreciated.