CINXE.COM
Ruby on Rails API
<!DOCTYPE html> <html lang="en"> <head> <title>Ruby on Rails API</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="stylesheet" href="./css/reset.css" type="text/css" media="screen" /> <link rel="stylesheet" href="./css/panel.css" type="text/css" media="screen" /> <link rel="stylesheet" href="./css/main.css" type="text/css" media="screen" /> <link rel="stylesheet" href="./css/github.css" type="text/css" media="screen" /> <script src="./js/jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script> <script src="./js/main.js" type="text/javascript" charset="utf-8"></script> <script src="./js/highlight.pack.js" type="text/javascript" charset="utf-8"></script> <script src="./js/turbolinks.js" type="text/javascript" charset="utf-8"></script> <script src="./js/search_index.js" type="text/javascript" charset="utf-8"></script> <script src="./js/searcher.js" type="text/javascript" charset="utf-8"></script> <script src="./panel/tree.js" type="text/javascript" charset="utf-8"></script> <script src="./js/searchdoc.js" type="text/javascript" charset="utf-8"></script> <meta name="data-rel-prefix" content="./"> <meta name="data-tree-keys" content='[]'> </head> <body> <a class="sr-only sr-only-focusable" href="#content" data-turbolinks="false">Skip to Content</a> <a class="sr-only sr-only-focusable" href="#search" data-turbolinks="false">Skip to Search</a> <input type="checkbox" id="hamburger" class="panel_checkbox"> <label class="panel_mobile_button" for="hamburger"><span></span> Menu</label> <nav class="panel panel_tree" id="panel" data-turbolinks-permanent> <div class="header"> <input type="text" placeholder="Search (/) for a class, method, ..." autosave="searchdoc" results="10" id="search" autocomplete="off" tabindex="-1" /> <label class="panel_mobile_button_close" for="hamburger"><span></span> Close</label> </div> <div class="tree"> <ul> </ul> </div> <div class="result"> <ul> </ul> </div> <a href="links.html" id="links">index</a> </nav> <div class="banner"> <span>Ruby on Rails 8.0.0</span><br /> <h2> RDOC_MAIN.md </h2> <ul class="files"> <li>railties/RDOC_MAIN.md</li> <li>Last modified: 2024-11-07 23:00:48 +0000</li> </ul> <div id="version-badge">v8.0.0</div> </div> <main id="bodyContent"> <div id="content"> <div class="description"> <h1 id="label-Welcome+to+Rails">Welcome to Rails</h1> <h2 id="label-What-27s+Rails-3F">What’s Rails?</h2> <p>Rails is a web-application framework that includes everything needed to create database-backed web applications according to the <a href="https://en.wikipedia.org/wiki/Model-view-controller">Model-View-Controller (MVC)</a> pattern.</p> <p>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.</p> <h2 id="label-Model+layer">Model layer</h2> <p>The <strong><em>Model layer</em></strong> 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 <code>ActiveRecord::Base</code>. <a href="files/activerecord/README_rdoc.html">Active Record</a> 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 <a href="files/activemodel/README_rdoc.html">Active Model</a> module.</p> <h2 id="label-View+layer">View layer</h2> <p>The <strong><em>View layer</em></strong> 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 <a href="files/actionview/README_rdoc.html">Action View</a>.</p> <h2 id="label-Controller+layer">Controller layer</h2> <p>The <strong><em>Controller layer</em></strong> 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 <code>ActionController::Base</code>. Action Dispatch and Action Controller are bundled together in <a href="files/actionpack/README_rdoc.html">Action Pack</a>.</p> <h2 id="label-Frameworks+and+libraries">Frameworks and libraries</h2> <p><a href="files/activerecord/README_rdoc.html">Active Record</a>, <a href="files/activemodel/README_rdoc.html">Active Model</a>, <a href="files/actionpack/README_rdoc.html">Action Pack</a>, and <a href="files/actionview/README_rdoc.html">Action View</a> can each be used independently outside Rails.</p> <p>In addition to that, Rails also comes with:</p> <ul><li> <p><a href="files/actionmailer/README_rdoc.html">Action Mailer</a>, a library to generate and send emails</p> </li><li> <p><a href="files/actionmailbox/README_md.html">Action Mailbox</a>, a library to receive emails within a Rails application</p> </li><li> <p><a href="files/activejob/README_md.html">Active Job</a>, a framework for declaring jobs and making them run on a variety of queuing backends</p> </li><li> <p><a href="files/actioncable/README_md.html">Action Cable</a>, a framework to integrate WebSockets with a Rails application</p> </li><li> <p><a href="files/activestorage/README_md.html">Active Storage</a>, a library to attach cloud and local files to Rails applications</p> </li><li> <p><a href="files/actiontext/README_md.html">Action Text</a>, a library to handle rich text content</p> </li><li> <p><a href="files/activesupport/README_rdoc.html">Active Support</a>, a collection of utility classes and standard library extensions that are useful for Rails, and may also be used independently outside Rails</p> </li></ul> <h2 id="label-Getting+Started">Getting Started</h2> <ol><li> <p>Install Rails at the command prompt if you haven't yet:</p> <pre><code>$ gem install rails </code></pre> </li><li> <p>At the command prompt, create a new Rails application:</p> <pre><code>$ rails new myapp </code></pre> <p>where "myapp" is the application name.</p> </li><li> <p>Change directory to <code>myapp</code> and start the web server:</p> <pre><code>$ cd myapp $ bin/rails server </code></pre> <p>Run with <code>--help</code> or <code>-h</code> for options.</p> </li><li> <p>Go to <code>http://localhost:3000</code> and you'll see the Rails bootscreen with your Rails and Ruby versions.</p> </li><li> <p>Follow the guidelines to start developing your application. You may find the following resources handy:</p> <ul><li> <p><a href="https://guides.rubyonrails.org/getting_started.html">Getting Started with Rails</a></p> </li><li> <p><a href="https://guides.rubyonrails.org">Ruby on Rails Guides</a></p> </li><li> <p><a href="https://api.rubyonrails.org">The API Documentation</a></p> </li></ul> </li></ol> <h2 id="label-Contributing">Contributing</h2> <p>We encourage you to contribute to Ruby on Rails! Please check out the <a href="https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails guide</a> for guidelines about how to proceed. <a href="https://contributors.rubyonrails.org">Join us!</a></p> <p>Trying to report a possible security vulnerability in Rails? Please check out our <a href="https://rubyonrails.org/security">security policy</a> for guidelines about how to proceed.</p> <p>Everyone interacting in Rails and its sub-projects’ codebases, issue trackers, chat rooms, and mailing lists is expected to follow the Rails <a href="https://rubyonrails.org/conduct">code of conduct</a>.</p> <h2 id="label-License">License</h2> <p>Ruby on Rails is released under the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p> </div> <!-- Methods --> </div> </main> </body> </html>