Rails Development
When to Use
- •Adding or modifying resources (routes, controllers, models, views).
- •Writing or changing migrations, validations, associations, scopes.
- •Implementing API or HTML endpoints and form/JSON handling.
Workflow
- •Follow the project's Ruby/Rails style rules (
.cursor/rules/.mdc files or CLAUDE.md instructions) for all generated code. - •Routing: Use
namespacefor admin/API grouping. Runbin/rails routesafter changes to verify. - •Controllers: Use strong parameters. Prefer
before_actionwith lexical scope. - •Models: When adding associations or validations, run the relevant specs or tests immediately.
- •Migrations: Do not rely on application-level defaults when the DB can enforce them. Run
bin/rails db:migrate:statusafter migration. - •Views: Prefer partials and helpers over inline logic. Use route/path helpers instead of hard-coded URLs.
Quick Checks
- •
bin/rails routes— verify routing after changes. - •
bin/rails db:migrate:status— ensure migrations are applied. - •
db:schema:load— ensure schema is loadable for a fresh DB. - •Run the relevant specs or tests after changing validations or associations.