Catch Hidden Lazy Loads in Development & Test
An innocent serializer rendering 50 invoices with nested customer names triggers 51 round-trip database queries. Turning on strict_loading catches accidental lazy associations immediately.
rubyapp/controllers/api/v1/invoices_controller.rb
invoices = Invoice
.includes(:customer, :line_items)
.strict_loading
.where(account_id: current_account.id)
.order(issued_at: :desc)
.limit(50)