Ruby on Rails

Published Oct 14, 2022
Contribute to Docs

Ruby on Rails, or “Rails”, is an open-source server-side framework written in Ruby and used for building web applications. Rails provides pre-built, boilerplate code that can be reused or customized in an application.

While particularly popular with startups, some well-known companies that use Rails include Airbnb, Basecamp, GitHub, Shopify, and SoundCloud.


Rails can be installed as a Ruby gem. However, the following must be installed beforehand:

  • Ruby version 2.7.0 or later (preferably the latest version).
  • SQLite3 is the default database for Rails.
  • Node.js (version 8.16.0 or later) for running JavaScript (JS) on a local machine.
  • Yarn (either version 1 or 2) for installing and managing JS packages.

Help with installing these prerequisites can be found in “Getting Started with Rails”.

Lastly, Rails can be installed with the following command:

gem install rails

The MVC Pattern

Rails uses a common structural pattern known as the Model-View-Controller (MVC) pattern. It categorizes a web application’s code into three interconnected parts:

  • The Model that defines the data structure of the application.
  • The Views that use templates to represent the visual parts, like the Model data, of the application.
  • The Controller that works between the Model and Views to perform business logic for the application.

Use Cases

Rails is used across many industries for building web apps and services. This includes applications like marketing websites, content management systems (CMSs), eCommerce sites, and custom web applications. Tasks for working with Rails may include:

  • Creating templates that generate web pages for the front-end.
  • Writing web services that return JSON for JS-based front-end applications.
  • Writing back-end code (on the server-side) and front-end code (on the client-side) with HTML, CSS, and JS.

All contributors

Looking to contribute?

Learn Ruby on Codecademy