N+1 queries on Rails basics
Just enough fundamentals to be fluent preloading associations with ActiveRecord, and start helping your team to avoid n+1 queries on production.
Read moreJust enough fundamentals to be fluent preloading associations with ActiveRecord, and start helping your team to avoid n+1 queries on production.
Read moreLearn different ways to solve n+1 queries beyond "includes", to be confident that you can handle tasks on complex data models and fix n+1 queries if they appear.
Read moreOne of the ways I have been using coding agents these days is to prototype small UI changes in an existing project. I use them as a tool to explore.
In this usage mode, I am not interested in the code. I am interested in how the options look. My objective...
Read moreThis week I made a refactor to remove a job (ActiveJob::Base) that was used only in recurring.yml, and call a class method directly instead.
Sometimes it is ok to have a job, but sometimes using the method can help you write a little less code. And...
Read moreI just released md_record, a Ruby gem that provides an ActiveRecord-like interface for markdown files with YAML frontmatter.
I have some posts about using lateral joins in rails to fetch the “top N” of each record. Some months ago Ben Sheldon helped me see a performance problem on the queries that I was using.
Here I try to explain the problem, the solution proposed by...
Read moreYesterday, I found myself struggling with “litesearch”, and in my frustration, I decided to create a simple “Searchable” module to perform a “LIKE” search but with a cleaner interface/API.
If you’re looking for a straightforward way to implement a...
Read moreI have already shared a way of implementing a “read-more” behavior truncating by the number of lines instead of the number of words.
But now I want to share how you can do it using the line-clamp css property.
I was reading about shoes.rb and, while scanning the book and walkthrough, I discovered a pattern that caught my attention for its power and simplicity.
The combination of “stacks” and “flows” allows you to build complex layouts, like the following...
Read moreN+1 queries are not always a problem, but I have seen that most of the n+1 queries that are really a problem are when we need to fetch data to compute something.
Here I will try to share some examples of posible expensive computations candidates to...
Read moreThere are many tools that can help you detect n+1 queries in different ways.
This is a little reference of some of those tools:
You don’t need to use all of them, but is good to know that they exists and how they can help you.
Imagine that you want to truncate a filename, but you want to keep showing the extension of the file. Like “A big file name that…awesome.pdf”. How would you do it?
Here I try to share knowledge and fixes to common problems and struggles for ruby on rails developers, like How to fetch the latest-N-of-each record or How to test that an specific mail was sent or a Capybara cheatsheet. You can see more examples on Most recent posts or all posts.