Froze rails gems
[depot.git] / vendor / rails / railties / doc / guides / html / command_line.html
diff --git a/vendor/rails/railties/doc/guides/html/command_line.html b/vendor/rails/railties/doc/guides/html/command_line.html
new file mode 100644 (file)
index 0000000..2add204
--- /dev/null
@@ -0,0 +1,434 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+       <title>A Guide to The Rails Command Line</title>
+       <!--[if lt IE 8]>
+       <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
+       <![endif]-->
+       <link href="stylesheets/base.css" media="screen" rel="Stylesheet" type="text/css" />
+       <link href="stylesheets/forms.css" media="screen" rel="Stylesheet" type="text/css" />
+       <link href="stylesheets/more.css" media="screen" rel="Stylesheet" type="text/css" />
+       <style type="text/css">
+               div#container {
+       max-width: 900px;
+       padding-bottom: 3em;
+}
+
+div#content {
+       margin-left: 200px;
+}
+
+div#container.notoc {
+       max-width: 600px;
+}
+
+.notoc div#content {
+       margin-left: 0;
+}
+
+pre {
+       line-height: 1.4em;
+}
+
+#content p tt {
+       background: #eeeeee;
+       border: solid 1px #cccccc;
+       padding: 3px;
+}
+
+dt {
+       font-weight: bold;
+}
+
+#content dt tt {
+       font-size: 10pt;
+}
+
+dd {
+       margin-left: 3em;
+}
+
+#content dt tt, #content pre tt {
+       background: none;
+       padding: 0;
+       border: 0;
+}
+
+#content .olist ol {
+       margin-left: 2em;
+}
+
+#header {
+       position: relative;
+       max-width: 840px;
+       margin-left: auto;
+       margin-right: auto;
+}
+
+#header.notoc {
+       max-width: 580px;
+}
+
+#logo {
+       position: absolute;
+       left: 10px;
+       top: 10px;
+       width: 110px;
+       height: 140px;
+}
+
+div#header h1#site_title {
+       background: url('images/ruby_on_rails_by_mike_rundle2.gif') top left no-repeat;
+       position: absolute;
+       width: 392px;
+       height: 55px;
+       left: 145px;
+       top: 20px;
+       margin: 0;
+       padding: 0;
+}
+
+#site_title span {
+       display: none;
+}
+
+#site_title_tagline {
+       display: none;
+}
+
+ul#navMain {
+       position: absolute;
+       margin: 0;
+       padding: 0;
+       top: 97px;
+       left: 145px;
+}
+
+.left-floaty, .right-floaty {
+       padding: 15px;
+}
+
+.admonitionblock,
+.tableblock {
+       margin-left: 1em;
+       margin-right: 1em;
+       margin-top: 0.25em;
+       margin-bottom: 1em;
+}
+
+.admonitionblock .icon {
+       padding-right: 8px;
+}
+
+.admonitionblock .content {
+       border: solid 1px #ffda78;
+       background: #fffebd;
+       padding: 10px;
+       padding-top: 8px;
+       padding-bottom: 8px;
+}
+
+.admonitionblock .title {
+       font-size: 140%;
+       margin-bottom: 0.5em;
+}
+
+.tableblock table {
+       border: solid 1px #aaaaff;
+       background: #f0f0ff;
+}
+
+.tableblock th {
+       background: #e0e0e0;
+}
+
+.tableblock th,
+.tableblock td {
+       padding: 3px;
+       padding-left: 5px;
+       padding-right: 5px;
+}
+
+.sidebarblock {
+       margin-top: 0.25em;
+       margin: 1em;
+       border: solid 1px #ccccbb;
+       padding: 8px;
+       background: #ffffe0;
+}
+
+.sidebarblock .sidebar-title {
+       font-size: 140%;
+       font-weight: 600;
+       margin-bottom: 0.3em;
+}
+
+.sidebarblock .sidebar-content > .para:last-child > p {
+       margin-bottom: 0;
+}
+
+.sidebarblock .sidebar-title a {
+       text-decoration: none;
+}
+
+.sidebarblock .sidebar-title a:hover {
+       text-decoration: underline;
+}
+
+       </style>
+</head>
+<body>
+       <div id="header" >
+               <div id="logo">
+                       <a href="index.html" title="Ruby on Rails"><img src="images/rails_logo_remix.gif" alt="Rails" height="140" width="110" /></a>
+               </div>
+               
+               <h1 id="site_title"><span>Ruby on Rails</span></h1>
+               <h2 id="site_title_tagline">Sustainable productivity for web-application development</h2>
+
+               <ul id="navMain">
+                       <li class="first-child"><a href="http://www.rubyonrails.org/" title="Ruby on Rails" class="ruby_on_rails">Ruby on Rails</a></li>
+                       <li><a class="manuals" href="index.html" title="Manuals Index">Guides Index</a></li>
+               </ul>
+       </div>
+
+       <div id="container">
+               
+               <div id="sidebar">
+                       <h2>Chapters</h2>
+                       <ol>
+                                       <li>
+                                       <a href="#_command_line_basics">Command Line Basics</a>
+                                               <ul>
+                                               
+                                                       <li><a href="#_rails">rails</a></li>
+                                               
+                                                       <li><a href="#_server">server</a></li>
+                                               
+                                                       <li><a href="#_generate">generate</a></li>
+                                               
+                                               </ul>
+                                       </li>
+                       </ol>
+               </div>
+               
+               <div id="content">
+                               <h1>A Guide to The Rails Command Line</h1>
+                       <div id="preamble">\r
+<div class="sectionbody">\r
+<div class="para"><p>Rails comes with every command line tool you'll need to</p></div>\r
+<div class="ilist"><ul>\r
+<li>\r
+<p>\r
+Create a Rails application\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Generate models, controllers, database migrations, and unit tests\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Start a development server\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Mess with objects through an interactive shell\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Profile and benchmark your new creation\r
+</p>\r
+</li>\r
+</ul></div>\r
+<div class="para"><p>&#8230; and much, much more! (Buy now!)</p></div>\r
+<div class="para"><p>This tutorial assumes you have basic Rails knowledge from reading the Getting Started with Rails Guide.</p></div>\r
+</div>\r
+</div>\r
+<h2 id="_command_line_basics">1. Command Line Basics</h2>\r
+<div class="sectionbody">\r
+<div class="para"><p>There are a few commands that are absolutely critical to your everyday usage of Rails. In the order of how much you'll probably use them are:</p></div>\r
+<div class="ilist"><ul>\r
+<li>\r
+<p>\r
+console\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+server\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+rake\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+generate\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+rails\r
+</p>\r
+</li>\r
+</ul></div>\r
+<div class="para"><p>Let's create a simple Rails application to step through each of these commands in context.</p></div>\r
+<h3 id="_rails">1.1. rails</h3>\r
+<div class="para"><p>The first thing we'll want to do is create a new Rails application by running the <tt>rails</tt> command after installing Rails.</p></div>\r
+<div class="admonitionblock">\r
+<table><tr>\r
+<td class="icon">\r
+<img src="./images/icons/note.png" alt="Note" />\r
+</td>\r
+<td class="content">You know you need the rails gem installed by typing <tt>gem install rails</tt> first, right? Okay, okay, just making sure.</td>\r
+</tr></table>\r
+</div>\r
+<div class="listingblock">\r
+<div class="content"><!-- Generator: GNU source-highlight 2.9\r
+by Lorenzo Bettini\r
+http://www.lorenzobettini.it\r
+http://www.gnu.org/software/src-highlite -->\r
+<pre><tt>$ rails commandsapp\r
+\r
+     create\r
+     create  app/controllers\r
+     create  app/helpers\r
+     create  app/models\r
+     <span style="color: #990000">...</span>\r
+     <span style="color: #990000">...</span>\r
+     create  log/production<span style="color: #990000">.</span>log\r
+     create  log/development<span style="color: #990000">.</span>log\r
+     create  log/test<span style="color: #990000">.</span>log\r
+</tt></pre></div></div>\r
+<div class="para"><p>Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box.</p></div>\r
+<div class="admonitionblock">\r
+<table><tr>\r
+<td class="icon">\r
+<img src="./images/icons/note.png" alt="Note" />\r
+</td>\r
+<td class="content">This output will seem very familiar when we get to the <tt>generate</tt> command. Creepy foreshadowing!</td>\r
+</tr></table>\r
+</div>\r
+<h3 id="_server">1.2. server</h3>\r
+<div class="para"><p>Let's try it! The <tt>server</tt> command launches a small web server written in Ruby named WEBrick which was also installed when you installed Rails. You'll use this any time you want to view your work through a web browser.</p></div>\r
+<div class="admonitionblock">\r
+<table><tr>\r
+<td class="icon">\r
+<img src="./images/icons/note.png" alt="Note" />\r
+</td>\r
+<td class="content">WEBrick isn't your only option for serving Rails. We'll get to that in a later section. [XXX: which section]</td>\r
+</tr></table>\r
+</div>\r
+<div class="para"><p>Here we'll flex our <tt>server</tt> command, which without any prodding of any kind will run our new shiny Rails app:</p></div>\r
+<div class="listingblock">\r
+<div class="content"><!-- Generator: GNU source-highlight 2.9\r
+by Lorenzo Bettini\r
+http://www.lorenzobettini.it\r
+http://www.gnu.org/software/src-highlite -->\r
+<pre><tt>$ cd commandsapp\r
+$ <span style="color: #990000">.</span>/script/server\r
+<span style="color: #990000">=&gt;</span> Booting WEBrick<span style="color: #990000">...</span>\r
+<span style="color: #990000">=&gt;</span> Rails <span style="color: #993399">2.2</span><span style="color: #990000">.</span><span style="color: #993399">0</span> application started on http<span style="color: #990000">://</span><span style="color: #993399">0.0</span><span style="color: #990000">.</span><span style="color: #993399">0.0</span><span style="color: #990000">:</span><span style="color: #993399">3000</span>\r
+<span style="color: #990000">=&gt;</span> Ctrl-C to shutdown server<span style="color: #990000">;</span> call with --help <span style="font-weight: bold"><span style="color: #0000FF">for</span></span> options\r
+<span style="color: #990000">[</span><span style="color: #993399">2008</span>-<span style="color: #993399">11</span>-<span style="color: #993399">04</span> <span style="color: #993399">10</span><span style="color: #990000">:</span><span style="color: #993399">11</span><span style="color: #990000">:</span><span style="color: #993399">38</span><span style="color: #990000">]</span> INFO  WEBrick <span style="color: #993399">1.3</span><span style="color: #990000">.</span><span style="color: #993399">1</span>\r
+<span style="color: #990000">[</span><span style="color: #993399">2008</span>-<span style="color: #993399">11</span>-<span style="color: #993399">04</span> <span style="color: #993399">10</span><span style="color: #990000">:</span><span style="color: #993399">11</span><span style="color: #990000">:</span><span style="color: #993399">38</span><span style="color: #990000">]</span> INFO  ruby <span style="color: #993399">1.8</span><span style="color: #990000">.</span><span style="color: #993399">5</span> <span style="color: #990000">(</span><span style="color: #993399">2006</span>-<span style="color: #993399">12</span>-<span style="color: #993399">04</span><span style="color: #990000">)</span> <span style="color: #990000">[</span>i486-linux<span style="color: #990000">]</span>\r
+<span style="color: #990000">[</span><span style="color: #993399">2008</span>-<span style="color: #993399">11</span>-<span style="color: #993399">04</span> <span style="color: #993399">10</span><span style="color: #990000">:</span><span style="color: #993399">11</span><span style="color: #990000">:</span><span style="color: #993399">38</span><span style="color: #990000">]</span> INFO  WEBrick<span style="color: #990000">::</span>HTTPServer<span style="font-style: italic"><span style="color: #9A1900">#start: pid=18994 port=3000</span></span>\r
+</tt></pre></div></div>\r
+<div class="para"><p>WHOA. With just three commands we whipped up a Rails server listening on port 3000. Go! Go right now to your browser and go to <a href="http://localhost:3000">http://localhost:3000</a>. I'll wait.</p></div>\r
+<div class="para"><p>See? Cool! It doesn't do much yet, but we'll change that.</p></div>\r
+<h3 id="_generate">1.3. generate</h3>\r
+<div class="para"><p>The <tt>generate</tt> command uses templates to create a whole lot of things. You can always find out what's available by running <tt>generate</tt> by itself. Let's do that:</p></div>\r
+<div class="listingblock">\r
+<div class="content"><!-- Generator: GNU source-highlight 2.9\r
+by Lorenzo Bettini\r
+http://www.lorenzobettini.it\r
+http://www.gnu.org/software/src-highlite -->\r
+<pre><tt>$ <span style="color: #990000">.</span>/script/generate\r
+Usage<span style="color: #990000">:</span> <span style="color: #990000">.</span>/script/generate generator <span style="color: #990000">[</span>options<span style="color: #990000">]</span> <span style="color: #990000">[</span>args<span style="color: #990000">]</span>\r
+\r
+<span style="color: #990000">...</span>\r
+<span style="color: #990000">...</span>\r
+\r
+Installed Generators\r
+  Builtin<span style="color: #990000">:</span> controller<span style="color: #990000">,</span> integration_test<span style="color: #990000">,</span> mailer<span style="color: #990000">,</span> migration<span style="color: #990000">,</span> model<span style="color: #990000">,</span> observer<span style="color: #990000">,</span> performance_test<span style="color: #990000">,</span> plugin<span style="color: #990000">,</span> resource<span style="color: #990000">,</span> scaffold<span style="color: #990000">,</span> session_migration\r
+\r
+<span style="color: #990000">...</span>\r
+<span style="color: #990000">...</span>\r
+</tt></pre></div></div>\r
+<div class="admonitionblock">\r
+<table><tr>\r
+<td class="icon">\r
+<img src="./images/icons/note.png" alt="Note" />\r
+</td>\r
+<td class="content">You can install more generators through generator gems, portions of plugins you'll undoubtedly install, and you can even create your own!</td>\r
+</tr></table>\r
+</div>\r
+<div class="para"><p>Using generators will save you a large amount of time by writing <strong>boilerplate code</strong> for you &#8212; necessary for the darn thing to work, but not necessary for you to spend time writing. That's what we have computers for, right?</p></div>\r
+<div class="para"><p>Let's make our own controller with the controller generator. But what command should we use? Let's ask the generator:</p></div>\r
+<div class="admonitionblock">\r
+<table><tr>\r
+<td class="icon">\r
+<img src="./images/icons/note.png" alt="Note" />\r
+</td>\r
+<td class="content">All Rails console utilities have help text. For commands that require a lot of input to run correctly, you can just try the command without any parameters (like <tt>rails</tt> or <tt>./script/generate</tt>). For others, you can try adding <tt>&#8212;help</tt> or <tt>-h</tt> to the end, as in <tt>./script/server &#8212;help</tt>.</td>\r
+</tr></table>\r
+</div>\r
+<div class="listingblock">\r
+<div class="content"><!-- Generator: GNU source-highlight 2.9\r
+by Lorenzo Bettini\r
+http://www.lorenzobettini.it\r
+http://www.gnu.org/software/src-highlite -->\r
+<pre><tt>$ <span style="color: #990000">.</span>/script/generate controller\r
+Usage<span style="color: #990000">:</span> <span style="color: #990000">.</span>/script/generate controller ControllerName <span style="color: #990000">[</span>options<span style="color: #990000">]</span>\r
+\r
+<span style="color: #990000">...</span>\r
+<span style="color: #990000">...</span>\r
+\r
+Example<span style="color: #990000">:</span>\r
+    `<span style="color: #990000">.</span>/script/generate controller CreditCard open debit credit close`\r
+\r
+    Credit card controller with URLs like /credit_card/debit<span style="color: #990000">.</span>\r
+        Controller<span style="color: #990000">:</span> app/controllers/credit_card_controller<span style="color: #990000">.</span>rb\r
+        Views<span style="color: #990000">:</span>      app/views/credit_card/debit<span style="color: #990000">.</span>html<span style="color: #990000">.</span>erb <span style="color: #990000">[...]</span>\r
+        Helper<span style="color: #990000">:</span>     app/helpers/credit_card_helper<span style="color: #990000">.</span>rb\r
+        Test<span style="color: #990000">:</span>       test/functional/credit_card_controller_test<span style="color: #990000">.</span>rb\r
+\r
+Modules Example<span style="color: #990000">:</span>\r
+    `<span style="color: #990000">.</span>/script/generate controller <span style="color: #FF0000">'admin/credit_card'</span> <span style="font-weight: bold"><span style="color: #0000FF">suspend</span></span> late_fee`\r
+\r
+    Credit card admin controller with URLs /admin/credit_card/suspend<span style="color: #990000">.</span>\r
+        Controller<span style="color: #990000">:</span> app/controllers/admin/credit_card_controller<span style="color: #990000">.</span>rb\r
+        Views<span style="color: #990000">:</span>      app/views/admin/credit_card/debit<span style="color: #990000">.</span>html<span style="color: #990000">.</span>erb <span style="color: #990000">[...]</span>\r
+        Helper<span style="color: #990000">:</span>     app/helpers/admin/credit_card_helper<span style="color: #990000">.</span>rb\r
+        Test<span style="color: #990000">:</span>       test/functional/admin/credit_card_controller_test<span style="color: #990000">.</span>rb\r
+</tt></pre></div></div>\r
+<div class="para"><p>Ah, the controller generator is expecting parameters in the form of <tt>generate controller ControllerName action1 action2</tt>. Let's make a <tt>Greetings</tt> controller with an action of <strong>hello</strong>, which will say something nice to us.</p></div>\r
+<div class="listingblock">\r
+<div class="content"><!-- Generator: GNU source-highlight 2.9\r
+by Lorenzo Bettini\r
+http://www.lorenzobettini.it\r
+http://www.gnu.org/software/src-highlite -->\r
+<pre><tt>$ <span style="color: #990000">.</span>/script/generate controller Greeting hello\r
+     exists  app/controllers<span style="color: #990000">/</span>\r
+     exists  app/helpers<span style="color: #990000">/</span>\r
+     create  app/views/greeting\r
+     exists  test/functional<span style="color: #990000">/</span>\r
+     create  app/controllers/greetings_controller<span style="color: #990000">.</span>rb\r
+     create  test/functional/greetings_controller_test<span style="color: #990000">.</span>rb\r
+     create  app/helpers/greetings_helper<span style="color: #990000">.</span>rb\r
+     create  app/views/greetings/hello<span style="color: #990000">.</span>html<span style="color: #990000">.</span>erb\r
+</tt></pre></div></div>\r
+<div class="para"><p>Look there! Now what all did this generate? It looks like it made sure a bunch of directories were in our application, and created a controller file, a functional test file, a helper for the view, and a view file. All from one command!</p></div>\r
+</div>\r
+
+               </div>
+       </div>
+</body>
+</html>