railslisted
Install: claude install-skill FortiumPartners/ensemble
# Rails Framework Skill - Quick Reference
**Framework**: Ruby on Rails 7+
**For Agent**: backend-developer
**Purpose**: Fast lookup of common Rails patterns and conventions
---
## 1. Rails MVC Patterns
### Controllers (RESTful Actions)
```ruby
class PostsController < ApplicationController
before_action :set_post, only: %i[show edit update destroy]
before_action :authenticate_user!, except: %i[index show]
def index
@posts = Post.published.order(created_at: :desc).page(params[:page])
end
def show
# @post set by before_action
end
def new
@post = Post.new
end
def create
@post = current_user.posts.build(post_params)
if @post.save
redirect_to @post, notice: 'Post created successfully.'
else
render :new, status: :unprocessable_entity
end
end
def edit
# @post set by before_action
end
def update
if @post.update(post_params)
redirect_to @post, notice: 'Post updated successfully.'
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@post.destroy
redirect_to posts_url, notice: 'Post deleted successfully.'
end
private
def set_post
@post = Post.find(params[:id])
end
def post_params
params.require(:post).permit(:title, :body, :published, :category_id, tag_ids: [])
end
end
```
### Models (Active Record)
```ruby
class Post < ApplicationRecord
# Associations
belongs_to :author, class_name: 'User'
belongs_to :category
has_many :c