Ruby on Rails
Switch branches/tags
Clone or download
rafaelfranca Make sure this test check the issue solved in #31135
Before this change this test was passing even if we revert #31135. The
reason for that is that `app 'development'` will load the environment in
the test process and it is happening before db_create_and_drop is

This was not asserting that the environment was loaded in the db:create
task itself.

To test it we enhance the db:create task with a block that writes to a
tmp file the value of the config. If the environment is loaded before
that task enhancement runs the content of the file will have "true"
insteand of "false".
Latest commit d3b9521 Sep 21, 2018
Failed to load latest commit information.
.github Update stale issue comment to mention 5-2-stable May 24, 2018
actioncable Fix test case to ensure default connection id is filled Sep 6, 2018
actionmailer Add changelog entries for #33849 [ci skip] Sep 13, 2018
actionpack Merge pull request #33934 from tgxworld/add_missing_test_case Sep 21, 2018
actionview Merge pull request #33564 from avit/escape_javascript_casting Sep 21, 2018
activejob Fix "warning: shadowing outer local variable - job" Sep 22, 2018
activemodel Merge pull request #33804 from yskkin/num_string Sep 7, 2018
activerecord No private def in the codebase Sep 21, 2018
activestorage Raise `ActiveRecord::InvalidForeignKey` in `before_destroy` for a blo… Sep 16, 2018
activesupport Switch to supports_cache_versioning? check to a class method Sep 21, 2018
ci Load `chromedriver-helper.rb` Sep 16, 2018
guides Replace line items with chapters [ci skip] Sep 21, 2018
railties Make sure this test check the issue solved in #31135 Sep 22, 2018
tasks Fix rubocop offenses Aug 15, 2018
tools Use frozen string literal in tools/ Aug 13, 2017
.codeclimate.yml Bump RuboCop to 0.58.2 Jul 26, 2018
.gitattributes adds .gitattributes to enable Ruby-awareness Mar 16, 2016
.gitignore Clean up and consolidate .gitignores Feb 17, 2018
.rubocop.yml Enable Style/ParenthesesAroundCondition cop Aug 18, 2018
.travis.yml CI against PostgreSQL 10 Sep 18, 2018
.yardopts Let YARD document the railties gem Sep 10, 2010
Brewfile [ci skip] Add ImageMagick to Brewfile Aug 22, 2018 Update CoC to change a history of updates URL [ci skip] Apr 19, 2018 Remove html tag making markdown misrender [ci skip] Jun 6, 2017
Gemfile Unlock pg verson Sep 15, 2018
Gemfile.lock Bump `chromedriver-helper` to 2.0 Sep 16, 2018
MIT-LICENSE Bump license years for 2018 Dec 31, 2017
RAILS_VERSION Start Rails 6.0 development!!! Jan 30, 2018 All links from now served over https Jul 31, 2018 Use https with weblog URI May 2, 2018
Rakefile Use frozen string literal in root files Aug 13, 2017
rails.gemspec Rails 6 requires Ruby 2.4.1+ Feb 17, 2018
version.rb Start Rails 6.0 development!!! Jan 30, 2018

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.

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.

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.

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; Active Job, a framework for declaring jobs and making them run on a variety of queueing 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; and 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
     $ rails server

    Run with --help or -h for options.

  4. Go to http://localhost:3000 and you'll see: "Yay! You’re on Rails!"

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


Code Triage Badge

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.

Code Status

Build Status


Ruby on Rails is released under the MIT License.