# Ruby on Rails — Full-Stack Web Framework That Started It All > Ruby on Rails is a full-stack web framework optimized for programmer happiness. Convention over configuration, MVC architecture, ActiveRecord ORM, migrations, and scaffolding. Created by DHH in 2004 and still powering GitHub, Shopify, Basecamp, and Airbnb. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash # Install Ruby and Rails gem install rails rails new myapp --database=postgresql cd myapp rails db:create rails server # Visit http://localhost:3000 ``` Scaffold a resource: ```bash rails generate scaffold Asset repo:string stars:integer description:text rails db:migrate # Visit http://localhost:3000/assets # Full CRUD ready: index, show, new, create, edit, update, destroy ``` Model with validations: ```ruby # app/models/asset.rb class Asset < ApplicationRecord validates :repo, presence: true, uniqueness: true validates :stars, numericality: { greater_than_or_equal_to: 0 } scope :popular, -> { where("stars >= ?", 10000).order(stars: :desc) } end ``` ```ruby # Rails console rails console > Asset.create(repo: "react", stars: 230000) > Asset.popular.limit(5) > Asset.where("stars > ?", 100000).count ``` ## Intro Ruby on Rails (often just "Rails") is a full-stack web application framework written in Ruby. Created by David Heinemeier Hansson (DHH) while building Basecamp, open-sourced in 2004. Rails popularized Convention over Configuration (CoC) and Don"t Repeat Yourself (DRY) — ideas that influenced every web framework since. Powers GitHub, Shopify, Basecamp, Airbnb, Hulu, and many others. - **Repo**: https://github.com/rails/rails - **Stars**: 58K+ - **Language**: Ruby - **License**: MIT ## What Rails Does - **MVC** — Model, View, Controller architecture - **ActiveRecord** — ORM with migrations, validations, associations - **Scaffold** — one-command CRUD generation - **Routing** — RESTful resource routing - **Action View** — ERB/Haml templates - **Action Cable** — WebSocket framework - **Active Job** — background job abstraction - **Action Mailer** — email sending with templates - **Active Storage** — file uploads to S3/GCS/Azure - **Turbo + Stimulus** — Hotwire for HTML-over-the-wire - **Kamal** — deploy Rails anywhere with Docker - **Solid Queue/Cache/Cable** — database-backed infrastructure ## Architecture Full MVC with an opinionated project structure. Convention over Configuration means file names, directory layouts, and naming patterns determine behavior. Asset pipeline (Propshaft/Dartsass in Rails 7+) for CSS/JS. Rails 8 introduces Solid trifecta for database-backed queues, caches, and WebSockets. ## Self-Hosting ```bash # Production (Rails 8) KAMAL_REGISTRY_PASSWORD=xxx kamal setup kamal deploy # Traditional bundle exec puma -C config/puma.rb # Behind Nginx reverse proxy ``` ## Key Features - Convention over Configuration - ActiveRecord ORM - Scaffold generators - RESTful routing - Hotwire (Turbo + Stimulus) - Action Cable (WebSocket) - Active Job (background) - Active Storage (uploads) - Kamal deployer - Rails 8 Solid trifecta - Mature gem ecosystem ## Comparison | Framework | Language | Philosophy | Speed | |---|---|---|---| | Rails | Ruby | Convention > config | OK | | Django | Python | Batteries-included | OK | | Laravel | PHP | Elegant syntax | OK | | Phoenix | Elixir | Convention + speed | Fast | | Spring Boot | Java | Enterprise auto-config | OK | | Next.js | TypeScript | Full-stack React | Fast | ## FAQ **Q: Rails performance?** A: Ruby 3.3 + YJIT makes Rails 3x faster than Ruby 2.x. Shopify runs a million global merchants on Rails. Performance bottlenecks are usually in the database, not the framework. **Q: Rails 7 vs 8?** A: Rails 8 introduces Solid Queue (DB-backed queue, no Redis needed), Solid Cache, and Solid Cable, simplifying deployment. Combined with the Kamal deployer, the goal is that even solo full-stack developers can deploy anywhere. **Q: What is Hotwire?** A: Turbo (HTML-over-the-wire, replacing SPAs) + Stimulus (lightweight JS sprinkles) + Strada (mobile bridge). Use Rails to build full-stack apps without React or a frontend/backend split. ## Sources - Docs: https://guides.rubyonrails.org - GitHub: https://github.com/rails/rails - License: MIT --- Source: https://tokrepo.com/en/workflows/ruby-rails-full-stack-web-framework-started-all-cc16545d Author: AI Open Source