rails-controllers
Installation
SKILL.md
Rails Controllers
Structure
- Only RESTful public actions:
index,show,new,create,edit,update,destroy - If a controller needs custom public methods, extract them to a new controller scoped to that feature
- Use
respond_toincreate,update, anddestroy— not inindexunless multi-format is needed
REST Mapping (resources, not verbs)
- For non-CRUD actions, create a new resource rather than a custom verb on the existing controller
POST /cards/:id/close→Cards::ClosuresController#create(POST /cards/:id/closure)DELETE /cards/:id/close→Cards::ClosuresController#destroyPOST /cards/:id/archive→Cards::ArchivalsController#create
- The new resource is often a real record (see "State as Records" in
rails-models), so the controller stays plainly RESTful
Configuration Order
Always declare configuration in this order:
- Authentication/authorization declarations
- Rate limiting
- Before actions