---
name: rails-d04b351d3957
slug: rails
version: 1.0.1
description: Build reliable Rails apps avoiding ActiveRecord traps, N+1 queries, and callback pitfalls.
homepage: https://clawic.com/skills/rails
metadata:
  clawdbot:
    emoji: 🛤️
    requires:
      bins:
      - rails
    os:
    - linux
    - darwin
    - win32
    displayName: Rails
---

## Quick Reference

| Topic | File |
|-------|------|
| N+1, callbacks, validations, scopes | `activerecord.md` |
| Strong params, filters, render | `controllers.md` |
| Route conflicts, constraints | `routing.md` |
| Partials, helpers, caching, XSS | `views.md` |
| ActiveJob, Sidekiq, retries | `jobs.md` |
| Mass assignment, CSRF, SQL injection | `security.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


---
Source attribution: clawic
Original project: https://github.com/clawic/skills/blob/f825206afbf1c697202533a9187be68c7b697e0e/skills/rails/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Ivan G. Davila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: clawic
Original project: https://github.com/clawic/skills/blob/f825206afbf1c697202533a9187be68c7b697e0e/skills/rails/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Backend Developer, Full-Stack Developer, Product Manager
Specialties: Backend
Tools: Rails
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 35da4ef4092495d6601c832cc0d01a4cad7a12d6e4a4e2d102214d90394960d7
