rails-patterns

Installation
SKILL.md

Rails Patterns

Follow these patterns when working in Rails applications.

Strict Loading for N+1 Prevention

  • New models should include self.strict_loading_by_default = true.
  • Resolve violations with .includes(:association) or .preload(:association).
  • Use :n_plus_one_only mode in development for practical DX.
  • Configure :log mode in production to prevent crashes.
  • Bypass in FactoryBot with record.strict_loading!(false) in after(:build) hooks.
class Article < ApplicationRecord
  self.strict_loading_by_default = true

  has_many :comments
  belongs_to :author
end
Installs
2
GitHub Stars
3
First Seen
Oct 9, 2026