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_onlymode in development for practical DX. - Configure
:logmode in production to prevent crashes. - Bypass in FactoryBot with
record.strict_loading!(false)inafter(:build)hooks.
class Article < ApplicationRecord
self.strict_loading_by_default = true
has_many :comments
belongs_to :author
end