High Rails

Fat models, skinny controllers

Rule Description

Keep controllers thin - they should only:
- Authenticate and authorize
- Parse params and set instance variables
- Call model/service methods
- Render response

Business logic belongs in:
- Models (for single-model operations)
- Service objects (for multi-model operations)
- Form objects (for complex form handling)
- Query objects (for complex queries)

```ruby
# Good: Thin controller
def create
@order = OrderCreator.new(order_params, current_user).call
respond_with @order
end
```

Included in Rulesets

Rails Standards
36 rules • 1 standard
View
Code Review Standards
58 rules • 0 standards
View

Add This Rule

Sign in to add this rule to your workspace

Sign in with GitHub

Details

Severity
High
Category
Rails
Used in
2 rulesets