Ruby on Rails: What is this web framework?
Définition
Ruby on Rails, often called Rails, is an open-source web framework written in Ruby. Created by David Heinemeier Hansson in 2004, it popularized the convention over configuration principle and the MVC pattern in web development. Rails was adopted by famous startups like Twitter, Shopify, and GitHub for its ability to create web applications rapidly.What is Ruby on Rails?
Ruby on Rails is a full-stack web framework written in Ruby, an object-oriented programming language created by Yukihiro Matsumoto in 1995. Rails was extracted from the project management tool Basecamp by David Heinemeier Hansson and released as open source in 2004. Its revolutionary approach profoundly influenced an entire generation of web frameworks, including Django in Python and Laravel in PHP.
Rails is built on two fundamental principles: Convention over Configuration (CoC) and DRY (Don't Repeat Yourself). The first principle means the framework enforces naming and structural conventions that eliminate the need for verbose configuration files. The second encourages code reuse and factoring to avoid redundancy. Combined, these principles allow developers to focus on business logic rather than technical plumbing.
The framework follows the MVC (Model-View-Controller) architectural pattern. Models interact with the database via Active Record, a built-in ORM that maps tables to Ruby classes. Controllers handle HTTP request logic, and views produce the HTML returned to the browser. This separation of concerns facilitates code maintenance and testing.
Why Ruby on Rails matters
Rails played a historic role in democratizing modern web development. Its influence is measured across the entire industry, as many concepts it popularized have become standards adopted by virtually all contemporary frameworks.
- High initial productivity: Rails includes code generators (scaffolding) that automatically create models, controllers, views, and database migrations. A functional prototype can be delivered in just a few days.
- Gem ecosystem: RubyGems, the Ruby package manager, offers thousands of libraries (called gems) for authentication (Devise), file management (Active Storage), payments (Stripe), and much more.
- Active Record: Rails' built-in ORM is powerful and expressive. It allows defining complex relationships between models (has_many, belongs_to, polymorphic) in a readable and intuitive way.
- Strict convention: the rigid structure imposed by Rails ensures consistency across projects. A Rails developer can pick up any Rails project and find their way immediately.
- Engaged community: although smaller than during its peak popularity around 2010-2015, the Rails community remains active and produces regular framework updates.
How it works
The lifecycle of a Rails request begins with the router, which analyzes the URL and HTTP method to determine which controller and action should handle the request. The Rails router uses a centralized file, config/routes.rb, where developers define application routes declaratively.
The controller then executes business logic, interacts with Active Record models to read or write data, and passes the results to the view. Rails uses ERB (Embedded Ruby) as its default template engine, although other options like Haml or Slim are available.
The Rails migration system allows versioning database schema changes. Each migration is a Ruby file with up and down methods that describe applying and rolling back a change, respectively. Rails natively supports PostgreSQL, MySQL, and SQLite.
Since Rails 7, the framework offers Hotwire (HTML Over The Wire) as an alternative to heavy JavaScript frameworks. Hotwire, composed of Turbo and Stimulus, enables creating reactive interfaces by sending HTML from the server rather than JSON, reducing client-side complexity.
Real-world example
Shopify, the e-commerce platform powering over 4 million online stores worldwide, is built on Ruby on Rails. This use case demonstrates that Rails can handle very large-scale applications, although it requires deep expertise in optimization and infrastructure scaling.
GitHub, the developer collaboration platform used by over 100 million people, was originally built on Rails. This origin contributed to strong Rails adoption in the open-source community during the 2008-2015 period.
For a startup looking to quickly validate a concept, Rails remains a relevant choice. Creating an MVP with authentication, a full CRUD system, a RESTAPI, and an admin interface can be accomplished in just a few weeks thanks to the framework's generators and conventions.
Implementation
- Installation: install Ruby via rbenv or RVM, then install Rails with
gem install rails. Ruby version management is essential as the framework depends heavily on the language version. - Project creation: use
rails new my_projectto generate the complete application structure, including MVC directories, configuration files, and a Gemfile for dependencies. - Modeling: define your models and their relationships with Active Record. Use migrations to create and modify the database schema in a versioned manner.
- Development: leverage Rails generators to accelerate controller and view creation. Follow naming conventions to fully benefit from Rails magic.
- Testing: Rails includes a built-in test framework (Minitest) and supports RSpec as an alternative. Write unit tests for models and integration tests for user flows.
- Deployment: Heroku was long the reference deployment platform for Rails. Today, Docker and platforms like Render or Fly.io offer modern alternatives.
Associated technologies and tools
- Ruby: the programming language on which Rails is built, recognized for its syntactic elegance.
- Active Record: Rails' built-in ORM, inspired by Martin Fowler's pattern of the same name.
- PostgreSQL: the most commonly used relational database with Rails in production.
- Sidekiq: background job processing system, equivalent to Celery in the Python ecosystem.
- Hotwire: a suite of tools (Turbo, Stimulus) for creating reactive interfaces without heavy JavaScript frameworks.
- RSpec: BDD (Behavior-Driven Development) testing framework very popular in the Rails community.
Conclusion
Ruby on Rails marked the history of web development by popularizing principles that are now universally adopted. The framework remains relevant for rapid prototyping and medium-sized applications, supported by a loyal community and a mature gem ecosystem. However, the Ruby job market is significantly less dynamic than Python's, which can create long-term recruitment challenges. For companies seeking similar productivity with a broader ecosystem and opportunities to expand into data science or artificial intelligence, Django and Python represent a solid alternative worth evaluating.
If you are evaluating Ruby on Rails for a new project, objectively compare the size of the available developer pool in your region with Python/Django. In Belgium and French-speaking Europe, Python developers are significantly more numerous, making recruitment easier and reducing dependency on rare profiles.