| name | rails-activerecord |
| description | Active Record: models, associations, validations, callbacks, scopes, and query interfaces. Use when working with persistence layer. |
Active Record
Model data with clear associations, validations, and query objects.
When to Use This Skill
- Associations and validations
- Scopes and
where chains
- Counter caches and touch
Defaults (This Plugin)
- Toolchain: mise — not rbenv, rvm, or asdf directly
- Ruby: 4.0.0+ unless the project pins otherwise
- Rails: 8+ conventions and generators when applicable
- Execution: Prefer
mise exec --, bin/rails, bin/rspec, and bundle exec
Core Guidance
-
Associations: Declare dependent: explicitly; prefer inverse_of where helpful.
-
Validations in model; database constraints for integrity (uniqueness with concurrency).
-
Callbacks sparingly — prefer explicit service calls over callback chains.
-
Query: Use includes/preload/eager_load intentionally; extract complex SQL to scope classes or app/queries.
-
Enums and Rails 8 attributes API for typed attributes.
-
Console:
mise exec -- bin/rails console
Quick Commands
mise exec -- bin/rails console
mise exec -- bin/rails dbconsole
Anti-Patterns
default_scope hiding data unexpectedly
update_column skipping validations/callbacks without intent
- Raw SQL strings without binds
See Also
- rails-database-migrations
- rails-performance