Benito Serna Tips and tools for Ruby on Rails developers

Preload object on the guide for preloading associations

September 13, 2021

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.

Visit the new section

You can visit the new section on Guide for preloading associations in rails - Preload Object. And a standalone article about it on Preload objects.

If you don’t know what this guide is about…

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 =)

Related articles

No more… “Why active record is ignoring my includes?”

Get for free the first part of the ebook Fix n+1 queries on Rails that will help you:

  • Explain what is an n+1 queries problem
  • Identify when ActiveRecord will execute a query
  • Solve the latest comment example
  • Detect n+1 queries by watching the logs
  • Learn the tools to detect n+1 queries
Get the first part of the ebook for free