1## Welcome to Rails
3Rails is a web-application framework that includes everything needed to
4create database-backed web applications according to the
8Understanding the MVC pattern is key to understanding Rails. MVC divides your
9application into three layers, each with a specific responsibility.
11The _Model layer_ represents your domain model (such as Account, Product,
12Person, Post, etc.) and encapsulates the business logic that is specific to
13your application. In Rails, database-backed model classes are derived from
14`ActiveRecord::Base`. Active Record allows you to present the data from
15database rows as objects and embellish these data objects with business logic
16methods. You can read more about Active Record in its [README](activerecord/README.rdoc).
17Although most Rails models are backed by a database, models can also be ordinary
18Ruby classes, or Ruby classes that implement a set of interfaces as provided by
19the Active Model module. You can read more about Active Model in its [README](activemodel/README.rdoc).
21The _Controller layer_ is responsible for handling incoming HTTP requests and
22providing a suitable response. Usually this means returning HTML, but Rails controllers
23can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and
24manipulate models, and render view templates in order to generate the appropriate HTTP response.
25In Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and
26controller classes are derived from `ActionController::Base`. Action Dispatch and Action Controller
27are bundled together in Action Pack. You can read more about Action Pack in its
30The _View layer_ is composed of "templates" that are responsible for providing
31appropriate representations of your application's resources. Templates can
32come in a variety of formats, but most view templates are HTML with embedded
33Ruby code (ERB files). Views are typically rendered to generate a controller response,
34or to generate the body of an email. In Rails, View generation is handled by Action View.
35You can read more about Action View in its [README](actionview/README.rdoc).
37Active Record, Active Model, Action Pack, and Action View can each be used independently outside Rails.
38In addition to them, Rails also comes with Action Mailer ([README](actionmailer/README.rdoc)), a library
39to generate and send emails; Active Job ([README](activejob/README.md)), a
40framework for declaring jobs and making them run on a variety of queueing
41backends; and Active Support ([README](activesupport/README.rdoc)), a collection
42of utility classes and standard library extensions that are useful for Rails,
43and may also be used independently outside Rails.
45## Getting Started
471. Install Rails at the command prompt if you haven't yet:
49 $ gem install rails
512. At the command prompt, create a new Rails application:
53 $ rails new myapp
55 where "myapp" is the application name.
573. Change directory to `myapp` and start the web server:
59 $ cd myapp
60 $ rails server
62 Run with `--help` or `-h` for options.
644. Using a browser, go to `http://localhost:3000` and you'll see:
65"Welcome aboard: You're riding Ruby on Rails!"
675. Follow the guidelines to start developing your application. You may find
68 the following resources handy:
69 * [Getting Started with Rails](http://guides.rubyonrails.org/getting_started.html)
70 * [Ruby on Rails Guides](http://guides.rubyonrails.org)
71 * [The API Documentation](http://api.rubyonrails.org)
72 * [Ruby on Rails Tutorial](http://www.railstutorial.org/book)
76We encourage you to contribute to Ruby on Rails! Please check out the
77[Contributing to Ruby on Rails guide](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html) for guidelines about how to proceed. [Join us!](http://contributors.rubyonrails.org)
79Everyone interacting in Rails and its sub-projects' codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Rails [code of conduct](http://rubyonrails.org/conduct/).
81## Code Status
87Ruby on Rails is released under the [MIT License](http://www.opensource.org/licenses/MIT).