Ruby on Rails
- Pronunciation
- ROO-bee on RAYLZ
In short
Ruby on Rails is a full-stack web framework for Ruby that favors convention over configuration, so database-backed web apps can be built quickly.
What is Ruby on Rails?
Rails was extracted by David Heinemeier Hansson from the Basecamp project management tool and released as open source in 2004. It popularized ideas that most web frameworks later borrowed: MVC with clear folders, database migrations, an ORM built into the framework, generators that create code for you, and sensible defaults for almost everything.
Convention over configuration is its core principle. A Book model automatically maps to a books table, a BooksController serves /books routes, and its views live in app/views/books. Because every Rails app is laid out the same way, developers can move between projects quickly, and a lot of code never has to be written.
Active Record, the built-in ORM, lets you write Book.where(author: "Le Guin").order(:year) instead of SQL. Hotwire, the default front-end approach, updates pages over the wire with HTML rather than a large JavaScript framework, and tools for background jobs, email, file uploads and WebSockets are built in. GitHub, Shopify and Basecamp are well-known Rails applications.
A common misconception is that Rails can't scale. Some of the largest websites run on it; scaling problems usually come from the database and architecture rather than the framework. Its real trade-off is that productivity depends on embracing its conventions and Ruby's style.
Key takeaways
- Rails is a full-stack Ruby web framework released in 2004.
- Convention over configuration means a standard structure and fewer decisions.
- Active Record maps models to tables; migrations version the schema.
- Generators, background jobs, mail and Hotwire come built in.
- GitHub and Shopify are large applications built on Rails.
Example
# config/routes.rb
Rails.application.routes.draw do
resources :books, only: [:index, :show]
end
# app/models/book.rb → table "books"
class Book < ApplicationRecord
validates :title, presence: true
scope :by_author, ->(name) { where(author: name).order(:year) }
end
# app/controllers/books_controller.rb → views in app/views/books/
class BooksController < ApplicationController
def index
@books = Book.by_author(params[:author])
end
def show
@book = Book.find(params[:id])
end
endReaders ask
Is Ruby on Rails still used?
Yes. It is actively developed and used by companies such as GitHub, Shopify and Basecamp, and it remains popular for startups that want to build quickly.
What does convention over configuration mean?
The framework assumes standard names and locations, such as a Book model using a books table, so you only write configuration when you need something different from the default.
What is the difference between Ruby and Rails?
Ruby is the programming language. Rails is a web framework written in Ruby. You can write Ruby without Rails, but Rails applications are written in Ruby.
See also
- RubyProgramming Languages, p. 28Ruby is a dynamic, object-oriented programming language designed for developer happiness, best known for readable syntax and the Ruby on Rails web framework.
- MVCSoftware Architecture, p. 29MVC is an architectural pattern that splits an application into a Model for data and logic, a View for display, and a Controller that handles user input.
- ORMDatabases, p. 33An ORM is a library that maps database tables to objects in your programming language, letting you read and write data with code instead of raw SQL.
- Database MigrationDatabases, p. 8A database migration is a versioned script that changes a database's schema, such as adding a column, so every environment applies the same changes in order.
- DRYSoftware Architecture, p. 16DRY is a software design principle stating that every piece of knowledge or logic should have one authoritative representation instead of being duplicated.
- DjangoBackend & APIs, p. 11Django is an open-source Python web framework that comes with an ORM, an admin panel, authentication and security protections, so teams can build quickly.
Spotted a mistake or something missing on this page?Suggest an edit