Ruby on Rails, usually called Rails, is an open-source server-side web framework written in the Ruby language that structures applications around the model-view-controller (MVC) pattern. In web architecture, it is the classic example of a full-stack, batteries-included framework: one codebase handles routing, database access, HTML rendering, background jobs, email and real-time updates.
Rails was extracted from a project-management product by David Heinemeier Hansson and released publicly in 2004. Its principles of convention over configuration and do not repeat yourself (DRY) strongly influenced later frameworks such as Django, Laravel and Phoenix.
How Ruby on Rails structures an application
A Rails application processes each HTTP request through a predictable chain. The router maps the URL to a controller action, the controller loads data through models, and a view renders the response, usually HTML built from ERB templates or JSON for an API. Middleware based on the Rack interface sits in front of this chain and handles sessions, cookies and security headers.
The framework is a collection of libraries, each named with an Active or Action prefix. The table below lists the most important components.
| Component | Responsibility | Typical use |
|---|---|---|
| Active Record | Object-relational mapping | Models, queries, validations, associations |
| Action Controller | Request handling | Parameters, sessions, redirects |
| Action View | Templates and helpers | HTML pages and partials |
| Active Job | Background job interface | Emails, exports, slow tasks |
| Action Cable | WebSocket integration | Live notifications and chat |
| Active Storage | File uploads | Attachments stored in cloud or disk |
| Action Mailer | Outgoing email | Account and transactional messages |
Convention over configuration in practice
Convention over configuration means that Rails infers behavior from names and file locations instead of requiring explicit settings. A model named Order maps automatically to an orders table, a controller named OrdersController lives in a predictable folder, and resourceful routes generate the seven standard actions for create, read, update and delete operations.
Generators and database migrations reinforce these conventions. A migration is a versioned Ruby file that changes the schema, so every developer and server can reach the same database structure by running pending migrations. The current schema is also stored in a single file, which makes it possible to rebuild a test database quickly.
Rails ships with an integrated testing framework based on Minitest, with fixtures, system tests that drive a real browser and generators that create test files next to the code. Its security defaults include protection against cross-site request forgery, automatic escaping of HTML output, encrypted credentials and parameterized SQL queries. The benefit is very high early productivity; the cost is that developers must learn the conventions to understand where behavior comes from.
Rails compared with other web frameworks
Rails belongs to the family of opinionated full-stack frameworks, in contrast to minimal frameworks that leave most decisions to the developer. The table compares it with neighboring frameworks in the same Topic.
| Framework | Language | Philosophy | Built-in scope |
|---|---|---|---|
| Ruby on Rails | Ruby | Opinionated, convention-driven | ORM, jobs, mail, WebSockets, assets |
| Django | Python | Opinionated, explicit configuration | ORM, admin interface, authentication |
| Laravel | PHP | Opinionated, Rails-inspired | ORM, queues, scheduling |
| Express.js | JavaScript on Node.js | Minimal and unopinionated | Routing and middleware only |
| Flask | Python | Micro framework | Routing and templating |
| ASP.NET Core | C# | Modular and typed | Broad, with dependency injection |
Rails traditionally follows a monolithic architecture, which its community defends as the most efficient structure for small and medium teams. It can also serve as a pure JSON backend for a single-page application or a mobile app through API-only mode.
Modern Rails: Hotwire and the default stack
Since Rails 7, the default frontend approach is Hotwire, which sends HTML over the wire instead of JSON. Turbo replaces page loads with fragment updates and streams, while Stimulus adds small JavaScript controllers to server-rendered markup. This is a form of progressive enhancement that delivers interactive interfaces with far less client-side JavaScript than a typical single-page application.
Recent versions also reduce infrastructure needs. Rails 8 added database-backed defaults for jobs, caching and WebSockets, known as Solid Queue, Solid Cache and Solid Cable, plus a built-in authentication generator and the Kamal deployment tool. The table summarizes the evolution of key defaults.
| Version | Year | Notable change |
|---|---|---|
| Rails 3 | 2010 | Merged with the Merb framework, modular core |
| Rails 5 | 2016 | Action Cable and API-only mode |
| Rails 6 | 2019 | Multiple databases and Action Text |
| Rails 7 | 2021 | Hotwire by default, import maps instead of bundling |
| Rails 8 | 2024 | Solid adapters, authentication generator, Kamal |
Limitations and common pitfalls of Rails
Rails optimizes for developer productivity rather than raw throughput. Ruby is slower than compiled languages for CPU-heavy work, although the YJIT compiler has narrowed the gap, and most web workloads are bound by database and network latency rather than CPU time.
- N+1 queries appear when code loads associations inside loops; eager loading with
includessolves most cases. - Fat models accumulate business logic until classes become hard to test; service objects or concerns keep responsibilities clear.
- Callback chains in Active Record can trigger hidden side effects and should be used sparingly.
- Delayed upgrades across several major versions become expensive, so teams should upgrade one version at a time.
- Mass assignment risks are handled by strong parameters, which must explicitly permit each accepted field.
A non-technical view
Building a website that stores data, such as an online shop or a booking system, involves many repetitive tasks. Ruby on Rails is a ready-made toolkit that already solves most of them. It works a bit like a well-organized workshop where every tool has a fixed place, so a new worker immediately knows where to find things.
Because Rails follows these fixed rules, small teams can build a working product quickly and keep it organized as it grows.
A concrete example
A three-person team at a regional veterinary clinic network needs an appointment system for twelve clinics. They choose Ruby on Rails because one framework covers the database, staff accounts, email reminders and the public booking pages.
Within the first weeks, they generate models for clinics, veterinarians, pets and appointments, use Active Job to send reminder emails the day before each visit, and use Turbo Streams so the reception screen updates instantly when an online booking arrives. The application runs as a single monolith on two servers with PostgreSQL. The outcome is a production system delivered in about three months by a small team, with no separate frontend application to maintain.