Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

rails

БесплатноБез исполняемых скриптовНе проверен

Ruby on Rails is a full-stack web framework with ActiveRecord ORM, controllers, views, Active Job, Action Cable and built-in authentication. Use when someone…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Ruby on Rails

Overview

Rails favors convention over configuration: generators create models, controllers, views, migrations and tests in standard places. This skill targets Rails 8.1 (8.1.4, September 2026). Defaults changed in Rails 8: new apps use SQLite, Propshaft, importmap, Turbo and Stimulus, plus the database-backed Solid Queue (jobs), Solid Cache and Solid Cable (Action Cable in production), so no Redis is needed. Rails 8 also ships a built-in authentication generator and Kamal deploy config. The code below was generated and run on Rails 8.1.4 with Ruby 3.4.

Instructions

1. Create the app

gem install rails
rails new shop                                   # SQLite + Solid trio, importmap
rails new shop --database=postgresql --css=tailwind
rails new shop_api --api                         # no views/assets, JSON only
cd shop && bin/rails db:create
bin/rails server                                 # http://localhost:3000 (bin/dev exists only with Tailwind or a JS bundler)

Flags such as --skip-kamal, --skip-docker, --skip-thruster drop generated deploy files. Use bin/rails (the binstub) so the project's Bundler versions load.

Layout: app/{models,controllers,views,jobs,channels,mailers}, config/routes.rb, config/database.yml, config/credentials.yml.enc, db/migrate, db/schema.rb, test/, plus config/queue.yml, config/cable.yml, config/ci.rb and bin/jobs.

2. Authentication (built in, no Devise needed)

bin/rails generate authentication
bin/rails db:migrate

This adds User (email_address, password_digest via has_secure_password), Session, Current (Current.user, Current.session), SessionsController, PasswordsController and an Authentication concern that is included in ApplicationController. Every action then requires a login; open specific ones with allow_unauthenticated_access only: %i[index show]. The generated code redirects to root_url after login, so the app must define a root route.

3. Models and migrations

bin/rails generate model Article title:string! slug:string:uniq body:text! published:boolean author:references

Edit the migration: author:references points at an authors table, so name the real one, and give booleans a default.

# db/migrate/20261024185513_create_articles.rb
class CreateArticles < ActiveRecord::Migration[8.1]
  def change
    create_table :articles do |t|
      t.string :title, null: false
      t.string :slug, null: false
      t.text :body, null: false
      t.boolean :published, null: false, default: false
      t.references :author, null: false, foreign_key: { to_table: :users }
      t.timestamps
    end
    add_index :articles, :slug, unique: true
  end
end
# app/models/article.rb
class Article < ApplicationRecord
  belongs_to :author, class_name: "User"

  validates :title, presence: true, length: { maximum: 200 }
  validates :slug, presence: true, uniqueness: true
  validates :body, presence: true

  scope :published, -> { where(published: true) }
  scope :recent, -> { order(created_at: :desc) }

  before_validation :generate_slug, on: :create

  private

  def generate_slug
    self.slug = title&.parameterize if slug.blank?
  end
end

Add has_many :articles, foreign_key: :author_id, inverse_of: :author, dependent: :destroy to User. Run bin/rails db:migrate; roll back with bin/rails db:rollback.

4. Routes and controller

# config/routes.rb
Rails.application.routes.draw do
  resource :session
  resources :passwords, param: :token
  root "articles#index"
  resources :articles, only: %i[index show create update destroy]
end
# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
  allow_unauthenticated_access only: %i[index show]
  before_action :set_article, only: %i[show update destroy]

  def index
    articles = Article.published.recent.includes(:author).limit(20).offset(page_offset)
    render json: articles.as_json(only: %i[id title slug created_at], include: { author: { only: :email_address } })
  end

  def show
    render json: @article
  end

  def create
    article = Current.user.articles.build(article_params)
    if article.save
      render json: article, status: :created
    else
      render json: { errors: article.errors }, status: :unprocessable_content
    end
  end

  def update
    if @article.update(article_params)
      render json: @article
    else
      render json: { errors: @article.errors }, status: :unprocessable_content
    end
  end

  def destroy
    @article.destroy!
    head :no_content
  end

  private

  def set_article
    @article = Article.find(params.expect(:id))
  end

  def article_params
    params.expect(article: %i[title body published])
  end

  def page_offset
    ([params[:page].to_i, 1].max - 1) * 20
  end
end

params.expect (Rails 8.0+) replaces params.require(...).permit(...): it also returns 400 inste

Полный SKILL.md на GitHub

Установить rails в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл rails?

Ruby on Rails is a full-stack web framework with ActiveRecord ORM, controllers, views, Active Job, Action Cable and built-in authentication. Use when someone asks to "create a Rails app", "add a model and migration", "build a Rails API endpoint", "add login to Rails", "run background jobs", "write Rails tests" or "upgrade to Rails 8".

Как установить скилл rails?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл rails запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить rails с