When Does an Active Record Query Actually Run?
03-Jul-2026 10
That reads like Rails went to the database and fetched overdue invoices.
It did not.
In the ordinary read path, this expression built an ActiveRecord::Relation. It gathered intent: which table, which conditions, which order, which model class should eventually receive the rows. But it did not necessarily send SQL to the database, receive rows, or instantiate Invoice objects.
That difference is easy to miss because Active Record relations are deliberately comfortable. You can chain them like queries, pass them through service objects, return them from scopes, hand them to views, and eventually treat them like collections.
That is the abstraction.
The database work may happen much later than the line where the query was described.
When Does an Active Record Query Actually Run? #ruby #rubydeveloper #rubyonrails #Active #Record #Query #Actually #active #record https://www.rubyonrails.ba/link/when-does-an-active-record-query-actually-run