Ruby on Rails
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Matthew Draper 55e4ddde1b
Merge pull request #46600 from matthewd/arel-sql-with-binds
13 hours ago
.devcontainer Update all the development gems 3 weeks ago
.github Use Ruby 3.2 for RuboCop workflow 4 weeks ago
actioncable Add changelog for #41415 4 days ago
actionmailbox Revert "Add nodoc to `Mail` module [ci-skip]" 2 days ago
actionmailer Gracefully degrade when `ActionMailer::Base#params` is nil 1 week ago
actionpack Merge pull request #47162 from stevenharman/document_exceptions_app_error_handling 2 days ago
actiontext Log to stdout in production by default (#47138) 5 days ago
actionview Several fixes for AV::Helpers::CaptureHelper 2 days ago
activejob Fix compatability between tests and Sidekiq 6.5 3 weeks ago
activemodel Improve Rails' Shape friendliness (second pass) 2 weeks ago
activerecord Merge pull request #46600 from matthewd/arel-sql-with-binds 13 hours ago
activestorage Merge pull request #47094 from zzak/rack-3-files-continued 5 days ago
activesupport Never report negative idle time 2 days ago
guides Simplify asset manifest example 24 hours ago
railties Unlink Rails constant, and fix RDoc link to files 2 days ago
tasks Update `rubocop-performance` and enable more performance-related cops 5 months ago
tools Replace webpack with importmapped Hotwire as default js (#42999) 1 year ago
.gitattributes adds .gitattributes to enable Ruby-awareness 7 years ago
.gitignore Remove unnecessary gitignore entry 5 months ago
.rubocop.yml Enable Style/EvalWithLocation 3 weeks ago
.yardopts Updating .yardopts to document .rb files in [GEM]/app 3 years ago
.yarnrc Make Webpacker the default JavaScript compiler for Rails 6 (#33079) 4 years ago
Brewfile Add libvips to Development Dependency guide 9 months ago Trim trailing whitespace from *.md files 1 month ago Add note about ActiveSupport to 3 months ago
Gemfile Use Gemfile to manage Rack version for dev 6 days ago
Gemfile.lock Merge PR #46594 5 days ago
MIT-LICENSE Bump license years to 2022 [ci-skip] 1 year ago
RAILS_VERSION Start Rails 7.1 development 1 year ago Convert lib and frameworks to bulleted list-README 12 months ago Add more instructions to RELEASING_RAILS 5 months ago
Rakefile Use frozen string literal in root files 6 years ago
codespell.txt use lower case for codespell ignore words 1 week ago
package.json Install JavaScript packages before run test 4 years ago
rails.gemspec Bump required_rubygems_version to 3.3.13 or higher 1 month ago
version.rb Fix #version docs and some typos 11 months ago
yarn.lock Update Action Text's Trix dependency 1 week ago

Welcome to Rails

What's Rails?

Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

Understanding the MVC pattern is key to understanding Rails. MVC divides your application into three layers: Model, View, and Controller, each with a specific responsibility.

Model layer

The Model layer represents the domain model (such as Account, Product, Person, Post, etc.) and encapsulates the business logic specific to your application. In Rails, database-backed model classes are derived from ActiveRecord::Base. Active Record allows you to present the data from database rows as objects and embellish these data objects with business logic methods. Although most Rails models are backed by a database, models can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as provided by the Active Model module.

View layer

The View layer is composed of "templates" that are responsible for providing appropriate representations of your application's resources. Templates can come in a variety of formats, but most view templates are HTML with embedded Ruby code (ERB files). Views are typically rendered to generate a controller response or to generate the body of an email. In Rails, View generation is handled by Action View.

Controller layer

The Controller layer is responsible for handling incoming HTTP requests and providing a suitable response. Usually, this means returning HTML, but Rails controllers can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and manipulate models, and render view templates in order to generate the appropriate HTTP response. In Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and controller classes are derived from ActionController::Base. Action Dispatch and Action Controller are bundled together in Action Pack.

Frameworks and libraries

Active Record, Active Model, Action Pack, and Action View can each be used independently outside Rails.

In addition to that, Rails also comes with:

  • Action Mailer, a library to generate and send emails
  • Action Mailbox, a library to receive emails within a Rails application
  • Active Job, a framework for declaring jobs and making them run on a variety of queuing backends
  • Action Cable, a framework to integrate WebSockets with a Rails application
  • Active Storage, a library to attach cloud and local files to Rails applications
  • Action Text, a library to handle rich text content
  • Active Support, a collection of utility classes and standard library extensions that are useful for Rails, and may also be used independently outside Rails

Getting Started

  1. Install Rails at the command prompt if you haven't yet:

     $ gem install rails
  2. At the command prompt, create a new Rails application:

     $ rails new myapp

    where "myapp" is the application name.

  3. Change directory to myapp and start the web server:

     $ cd myapp
     $ bin/rails server

    Run with --help or -h for options.

  4. Go to http://localhost:3000 and you'll see the Rails bootscreen with your Rails and Ruby versions.

  5. Follow the guidelines to start developing your application. You may find the following resources handy:


We encourage you to contribute to Ruby on Rails! Please check out the Contributing to Ruby on Rails guide for guidelines about how to proceed. Join us!

Trying to report a possible security vulnerability in Rails? Please check out our security policy for guidelines about how to proceed.

Everyone interacting in Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Rails code of conduct.


Ruby on Rails is released under the MIT License.