I want to tell you that I have added a new section to the guide for preloading associations in rails, to introduce you to something I call “Preload objects” that will help you build complex preloads for those cases when you can’t find a way to do what you need to do, with the standard rails mechanisms.
You can visit the new section on Guide for preloading associations in rails - Preload Object. And a standalone article about it on Preload objects.
Is a guide I wrote to try to help you get better on this specific skill of
preloading associations, for when you need a more than just a
preload(:comments)
.
To help you tackle problems like complex nested associations, scopes that you need or want to reuse, places where preloading all the associated records could hurt the performance of your app.
I hope it can help you =)
Making things work isn't enough for you any more? Now you need to consider performance and scalability?
... But you normally have troubles fixing n+1 queries and trying to find why active record is ignoring your "includes"?
Are you are worried because you feel unqualified to tackle tasks with complex data models?
Sign up to learn how to fix n+1 queries on Rails