You are totally correct, it really does what you said, which is the best solution. But I too share your problem: TextPost and Picture have comments (which I'd like to eagerly load), and SpreadSheet has collaborators, which I'd also like to eagerly load.
Yeah, but thats exactly what I wanted to avoid doing. My model is this message board:
A User has FeedItems. Each feed item is polymorphically related to one other model object e.g. TextPost, Picture, File, SpreadSheet and many more, via FeedItem's postable polymorphic property
So the problem here is with FeedItem: When showing User's FeedItems, I want to do something like:
Great episode! But I was hoping you'd touch eager loading with polymorphic associations. I couldn't find good information about it, and I feel it's a common problem.
You are totally correct, it really does what you said, which is the best solution. But I too share your problem:
TextPostandPicturehave comments (which I'd like to eagerly load), andSpreadSheethas collaborators, which I'd also like to eagerly load.Yeah, but thats exactly what I wanted to avoid doing. My model is this message board:
A
UserhasFeedItems. Each feed item is polymorphically related to one other model object e.g.TextPost,Picture,File,SpreadSheetand many more, viaFeedItem'spostablepolymorphic propertySo the problem here is with
FeedItem: When showingUser'sFeedItems, I want to do something like:But since
postableis polymorphic, i cant and i get the n+1 problem...Great episode! But I was hoping you'd touch eager loading with polymorphic associations. I couldn't find good information about it, and I feel it's a common problem.