Ruby on Rails Explained: Web Apps by Convention, Not Configuration

Introduction

Most web frameworks give you pieces and ask you to wire them together. Ruby on Rails, released in 2004 by David Heinemeier Hansson from the Basecamp codebase, gives you the whole app structure up front: where models live, how URLs map to code, and how database tables become objects. That opinionated structure is the point. Follow the conventions and a small team can ship a complete web app, database, pages, forms, and email, in days rather than weeks.

Convention over configuration, MVC, and Active Record

Rails rests on a few distinctive ideas:

  • Convention over configuration: file names, class names, and table names follow patterns, so Rails can guess what you mean instead of asking you to spell it out.
  • MVC, built in: models hold data and rules, controllers handle requests, views render pages, and the three have a fixed home in every Rails app.
  • Active Record: a database table becomes a class, a row becomes an object, and queries read like plain Ruby instead of SQL strings.
  • Everything in one box: routing, database migrations, form helpers, background jobs, and mailers ship together, so a new app needs few extra decisions.

A tiny example shows the shape, an articles listing built from three small files:

# config/routes.rb
Rails.application.routes.draw do
  resources :articles, only: [:index, :show]
end

# app/models/article.rb
class Article < ApplicationRecord
  validates :title, presence: true
end

# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
  def index
    @articles = Article.all
  end
end

resources :articles creates the routes for listing and showing articles, validates :title, presence: true makes a title required, and Article.all returns every row as an object. The view then loops over @articles and renders each one. Naming does most of the work.

The honest trade

Rails trades flexibility and raw speed for speed of development: its conventions feel restrictive when an app outgrows them, its "magic" can hide what is happening until something breaks, and very high traffic apps often need careful tuning. When to reach for it: when building a database-backed web app quickly with a small team; a lighter framework or a different language when the app is unusual enough that the conventions fight you.

Conventions that ship

Ruby on Rails is web apps by convention, not configuration: MVC structure, Active Record models, and a full toolbox in one framework, in a language that reads like plain English. It trades some freedom for shipping speed, and for teams that want a working app this week, that trade is the whole appeal.

Comments

Popular posts from this blog

Swift Explained: Apple's Language for iPhone, Mac, and More

Neovim Explained: Vim Rebuilt for the Modern Era

Rust Explained: Memory Safety Without a Garbage Collector