rails-waylisted
Install: claude install-skill ghozimahdi/gm-aiagent-plugins
## Rails Way Patterns
### Core Principles
- **Convention over Configuration** — follow Rails conventions
- **DRY** — don't repeat yourself
- **Thin controllers, fat models** — business logic in models/concerns
### Controller Rules
- HTTP flow only: receive request, call model, render response
- No business logic, no conditionals, no calculations
- Always use strong parameters
- Query through parent associations
```ruby
# Good — thin controller
class Admin::UsersController < Admin::ApplicationController
def create
@user = current_admin.users.build(user_params)
if @user.save
redirect_to [:admin, @user], notice: t('.success')
else
render :new, status: :unprocessable_entity
end
end
private
def user_params
params.require(:user).permit(:name, :email)
end
end
```
### Model Rules
- Validations for data integrity
- Callbacks for lifecycle events
- Scopes for chainable queries
- **Business logic only** — display/presentation logic belongs in helpers
- `class << self` for class methods (NOT `def self.`)
- Enum predicate methods: `task.pending?` (NOT `task.status == "pending"`)
- Enum scopes: `Task.status_pending` (NOT `Task.where(status: :pending)`)
```ruby
class Task < ApplicationRecord
include Task::StatusTransitions
include AttributeLabels
acts_as_paranoid
belongs_to :user
validates :title, presence: true
enum :status, { pending: 0, in_progress: 1, completed: 2 }
scope :due_soon, -> { where(due_at: ..3.days.from_now) }