ConfigsApr 12, 2026·3 min read

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.

TL;DR
Rails provides convention-over-configuration MVC, ActiveRecord ORM, scaffolding, and rapid prototyping for web applications.
§01

What it is

Ruby on Rails is a full-stack web framework built on the Ruby programming language. Created by DHH in 2004, it popularized conventions like MVC architecture, convention over configuration, and database migrations. Rails includes ActiveRecord ORM, Action Cable for WebSockets, Active Storage for file uploads, and built-in testing frameworks.

Rails is designed for developers who value productivity and convention-driven development, enabling rapid prototyping and production deployment of web applications.

§02

How it saves time or tokens

Rails generators and scaffolding produce working CRUD interfaces in seconds. The convention-over-configuration philosophy means you write less configuration code: database tables map to models automatically, routes follow RESTful conventions, and views follow naming patterns. A feature that requires extensive boilerplate in other frameworks is often a one-liner in Rails. Migrations make database schema changes trackable and reversible.

§03

How to use

  1. Install Rails and create a new project:
gem install rails
rails new myapp --database=postgresql
cd myapp
rails db:create
rails server
# Visit http://localhost:3000
  1. Scaffold a resource:
rails generate scaffold Post title:string body:text published:boolean
rails db:migrate
  1. Visit http://localhost:3000/posts for a complete CRUD interface with forms, validation, and JSON API.
§04

Example

A complete API endpoint with validation and authentication:

# app/models/post.rb
class Post < ApplicationRecord
  belongs_to :user
  validates :title, presence: true, length: { maximum: 100 }
  validates :body, presence: true
  scope :published, -> { where(published: true) }
end

# app/controllers/api/posts_controller.rb
class Api::PostsController < ApplicationController
  before_action :authenticate_user!

  def index
    posts = Post.published.order(created_at: :desc).limit(20)
    render json: posts
  end

  def create
    post = current_user.posts.build(post_params)
    if post.save
      render json: post, status: :created
    else
      render json: { errors: post.errors }, status: :unprocessable_entity
    end
  end

  private

  def post_params
    params.require(:post).permit(:title, :body, :published)
  end
end
§05

Related on TokRepo

§06

Common pitfalls

  • N+1 query problems. ActiveRecord makes it easy to trigger N+1 queries with associations. Use includes(:association) or tools like Bullet to detect and fix them.
  • Not running migrations in production before deploying code. The deploy process should run rails db:migrate before restarting the application to avoid schema mismatches.
  • Over-relying on scaffolding for production code. Scaffolding is a starting point, not production-ready code. Customize the generated controllers and views for your specific requirements.
  • Starting with an overly complex configuration instead of defaults. Begin with the minimal setup, verify it works, then customize incrementally. This approach catches configuration errors early and keeps troubleshooting straightforward.

Frequently Asked Questions

Is Rails still relevant in 2026?+

Yes. Rails powers major applications like Shopify, GitHub, Basecamp, and Hey. The framework continues to evolve with features like Hotwire for real-time UIs without JavaScript frameworks. Its productivity advantages remain compelling for many use cases.

How does Rails handle background jobs?+

Rails includes Active Job, a unified interface for background job processing. It works with backends like Sidekiq, Resque, and Solid Queue (Rails 8 default). Jobs handle tasks like email sending, data processing, and API calls.

Can Rails build APIs without views?+

Yes. Use rails new myapp --api to create an API-only Rails application. This skips view-related middleware and generators, producing a lean JSON API framework.

What is Hotwire in Rails?+

Hotwire (HTML Over The Wire) is Rails' approach to building real-time, reactive web applications without writing custom JavaScript. It includes Turbo (page navigation, frames, streams) and Stimulus (lightweight JS controllers).

How does Rails deployment work?+

Rails can be deployed with Kamal (Docker-based), Heroku, Render, or traditional server setups with Puma as the app server and Nginx as the reverse proxy. Rails 8 introduced Kamal as the default deployment tool.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets