Назад към всички

Rails

// Build reliable Rails apps avoiding ActiveRecord traps, N+1 queries, and callback pitfalls.

$ git log --oneline --stat
stars:1,933
forks:367
updated:March 4, 2026
SKILL.mdreadonly
SKILL.md Frontmatter
nameRails
slugrails
version1.0.1
descriptionBuild reliable Rails apps avoiding ActiveRecord traps, N+1 queries, and callback pitfalls.
metadata[object Object]

Quick Reference

TopicFile
N+1, callbacks, validations, scopesactiverecord.md
Strong params, filters, rendercontrollers.md
Route conflicts, constraintsrouting.md
Partials, helpers, caching, XSSviews.md
ActiveJob, Sidekiq, retriesjobs.md
Mass assignment, CSRF, SQL injectionsecurity.md

Critical Rules

  • save returns false on failure — save! raises, check return or use bang
  • update_all/delete_all skip callbacks and validations — data corruption if unaware
  • find_each for batches — Model.all.each loads entire table into memory
  • redirect_to doesn't halt execution — code after it runs, use and return
  • dependent: :destroy missing — orphan records accumulate forever
  • default_scope pollutes all queries including joins — almost always wrong
  • Callbacks chain silently — throw :abort stops save but returns false, not exception
  • includes without references in where string — N+1 still happens
  • ||= memoization caches nil/false — use defined?(@var) ? @var : @var = compute
  • has_many through: vs has_and_belongs_to_many — latter has no join model for attrs
  • Nested before_action — multiple inheritance makes flow unreadable
  • render doesn't stop action — code continues, duplicate render crashes