railties 3.1.3 → 3.1.4.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/CHANGELOG.md +17 -2
  2. data/guides/source/3_1_release_notes.textile +107 -0
  3. data/guides/source/active_record_querying.textile +1 -1
  4. data/guides/source/asset_pipeline.textile +3 -11
  5. data/guides/source/configuring.textile +3 -1
  6. data/guides/source/i18n.textile +1 -1
  7. data/guides/source/performance_testing.textile +1 -1
  8. data/guides/source/routing.textile +1 -1
  9. data/lib/rails/application.rb +21 -1
  10. data/lib/rails/application/configuration.rb +3 -1
  11. data/lib/rails/generators/app_base.rb +19 -5
  12. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -0
  13. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +4 -0
  14. data/lib/rails/tasks/documentation.rake +1 -1
  15. data/lib/rails/version.rb +2 -2
  16. metadata +335 -491
  17. data/guides/output/2_2_release_notes.html +0 -565
  18. data/guides/output/2_3_release_notes.html +0 -713
  19. data/guides/output/3_0_release_notes.html +0 -652
  20. data/guides/output/3_1_release_notes.html +0 -670
  21. data/guides/output/action_controller_overview.html +0 -925
  22. data/guides/output/action_mailer_basics.html +0 -658
  23. data/guides/output/action_view_overview.html +0 -1471
  24. data/guides/output/active_model_basics.html +0 -349
  25. data/guides/output/active_record_basics.html +0 -364
  26. data/guides/output/active_record_querying.html +0 -1272
  27. data/guides/output/active_record_validations_callbacks.html +0 -1292
  28. data/guides/output/active_resource_basics.html +0 -252
  29. data/guides/output/active_support_core_extensions.html +0 -3374
  30. data/guides/output/ajax_on_rails.html +0 -412
  31. data/guides/output/api_documentation_guidelines.html +0 -317
  32. data/guides/output/asset_pipeline.html +0 -691
  33. data/guides/output/association_basics.html +0 -1742
  34. data/guides/output/caching_with_rails.html +0 -533
  35. data/guides/output/command_line.html +0 -662
  36. data/guides/output/configuring.html +0 -811
  37. data/guides/output/contribute.html +0 -216
  38. data/guides/output/contributing_to_ruby_on_rails.html +0 -465
  39. data/guides/output/credits.html +0 -210
  40. data/guides/output/debugging_rails_applications.html +0 -791
  41. data/guides/output/engines.html +0 -673
  42. data/guides/output/form_helpers.html +0 -850
  43. data/guides/output/generators.html +0 -725
  44. data/guides/output/getting_started.html +0 -1980
  45. data/guides/output/i18n.html +0 -1054
  46. data/guides/output/images/belongs_to.png +0 -0
  47. data/guides/output/images/book_icon.gif +0 -0
  48. data/guides/output/images/bullet.gif +0 -0
  49. data/guides/output/images/challenge.png +0 -0
  50. data/guides/output/images/chapters_icon.gif +0 -0
  51. data/guides/output/images/check_bullet.gif +0 -0
  52. data/guides/output/images/credits_pic_blank.gif +0 -0
  53. data/guides/output/images/csrf.png +0 -0
  54. data/guides/output/images/customized_error_messages.png +0 -0
  55. data/guides/output/images/edge_badge.png +0 -0
  56. data/guides/output/images/error_messages.png +0 -0
  57. data/guides/output/images/feature_tile.gif +0 -0
  58. data/guides/output/images/footer_tile.gif +0 -0
  59. data/guides/output/images/fxn.png +0 -0
  60. data/guides/output/images/grey_bullet.gif +0 -0
  61. data/guides/output/images/habtm.png +0 -0
  62. data/guides/output/images/has_many.png +0 -0
  63. data/guides/output/images/has_many_through.png +0 -0
  64. data/guides/output/images/has_one.png +0 -0
  65. data/guides/output/images/has_one_through.png +0 -0
  66. data/guides/output/images/header_backdrop.png +0 -0
  67. data/guides/output/images/header_tile.gif +0 -0
  68. data/guides/output/images/i18n/demo_html_safe.png +0 -0
  69. data/guides/output/images/i18n/demo_localized_pirate.png +0 -0
  70. data/guides/output/images/i18n/demo_translated_en.png +0 -0
  71. data/guides/output/images/i18n/demo_translated_pirate.png +0 -0
  72. data/guides/output/images/i18n/demo_translation_missing.png +0 -0
  73. data/guides/output/images/i18n/demo_untranslated.png +0 -0
  74. data/guides/output/images/icons/README +0 -5
  75. data/guides/output/images/icons/callouts/1.png +0 -0
  76. data/guides/output/images/icons/callouts/10.png +0 -0
  77. data/guides/output/images/icons/callouts/11.png +0 -0
  78. data/guides/output/images/icons/callouts/12.png +0 -0
  79. data/guides/output/images/icons/callouts/13.png +0 -0
  80. data/guides/output/images/icons/callouts/14.png +0 -0
  81. data/guides/output/images/icons/callouts/15.png +0 -0
  82. data/guides/output/images/icons/callouts/2.png +0 -0
  83. data/guides/output/images/icons/callouts/3.png +0 -0
  84. data/guides/output/images/icons/callouts/4.png +0 -0
  85. data/guides/output/images/icons/callouts/5.png +0 -0
  86. data/guides/output/images/icons/callouts/6.png +0 -0
  87. data/guides/output/images/icons/callouts/7.png +0 -0
  88. data/guides/output/images/icons/callouts/8.png +0 -0
  89. data/guides/output/images/icons/callouts/9.png +0 -0
  90. data/guides/output/images/icons/caution.png +0 -0
  91. data/guides/output/images/icons/example.png +0 -0
  92. data/guides/output/images/icons/home.png +0 -0
  93. data/guides/output/images/icons/important.png +0 -0
  94. data/guides/output/images/icons/next.png +0 -0
  95. data/guides/output/images/icons/note.png +0 -0
  96. data/guides/output/images/icons/prev.png +0 -0
  97. data/guides/output/images/icons/tip.png +0 -0
  98. data/guides/output/images/icons/up.png +0 -0
  99. data/guides/output/images/icons/warning.png +0 -0
  100. data/guides/output/images/jaimeiniesta.jpg +0 -0
  101. data/guides/output/images/nav_arrow.gif +0 -0
  102. data/guides/output/images/polymorphic.png +0 -0
  103. data/guides/output/images/posts_index.png +0 -0
  104. data/guides/output/images/radar.png +0 -0
  105. data/guides/output/images/rails_guides_logo.gif +0 -0
  106. data/guides/output/images/rails_logo_remix.gif +0 -0
  107. data/guides/output/images/rails_welcome.png +0 -0
  108. data/guides/output/images/session_fixation.png +0 -0
  109. data/guides/output/images/tab_grey.gif +0 -0
  110. data/guides/output/images/tab_info.gif +0 -0
  111. data/guides/output/images/tab_note.gif +0 -0
  112. data/guides/output/images/tab_red.gif +0 -0
  113. data/guides/output/images/tab_yellow.gif +0 -0
  114. data/guides/output/images/tab_yellow.png +0 -0
  115. data/guides/output/images/validation_error_messages.png +0 -0
  116. data/guides/output/images/vijaydev.jpg +0 -0
  117. data/guides/output/index.html +0 -300
  118. data/guides/output/initialization.html +0 -1087
  119. data/guides/output/javascripts/guides.js +0 -7
  120. data/guides/output/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  121. data/guides/output/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  122. data/guides/output/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  123. data/guides/output/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  124. data/guides/output/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  125. data/guides/output/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  126. data/guides/output/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  127. data/guides/output/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  128. data/guides/output/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  129. data/guides/output/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  130. data/guides/output/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  131. data/guides/output/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  132. data/guides/output/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  133. data/guides/output/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  134. data/guides/output/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  135. data/guides/output/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  136. data/guides/output/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  137. data/guides/output/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  138. data/guides/output/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  139. data/guides/output/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  140. data/guides/output/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  141. data/guides/output/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  142. data/guides/output/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  143. data/guides/output/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  144. data/guides/output/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  145. data/guides/output/javascripts/syntaxhighlighter/shCore.js +0 -17
  146. data/guides/output/layout.html +0 -312
  147. data/guides/output/layouts_and_rendering.html +0 -1257
  148. data/guides/output/migrations.html +0 -751
  149. data/guides/output/nested_model_forms.html +0 -350
  150. data/guides/output/performance_testing.html +0 -858
  151. data/guides/output/plugins.html +0 -590
  152. data/guides/output/rails_application_templates.html +0 -368
  153. data/guides/output/rails_on_rack.html +0 -408
  154. data/guides/output/routing.html +0 -1246
  155. data/guides/output/ruby_on_rails_guides_guidelines.html +0 -218
  156. data/guides/output/security.html +0 -968
  157. data/guides/output/stylesheets/fixes.css +0 -16
  158. data/guides/output/stylesheets/main.css +0 -445
  159. data/guides/output/stylesheets/print.css +0 -52
  160. data/guides/output/stylesheets/reset.css +0 -43
  161. data/guides/output/stylesheets/style.css +0 -13
  162. data/guides/output/stylesheets/syntaxhighlighter/shCore.css +0 -226
  163. data/guides/output/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  164. data/guides/output/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  165. data/guides/output/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  166. data/guides/output/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  167. data/guides/output/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  168. data/guides/output/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  169. data/guides/output/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  170. data/guides/output/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  171. data/guides/output/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  172. data/guides/output/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  173. data/guides/output/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  174. data/guides/output/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  175. data/guides/output/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  176. data/guides/output/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  177. data/guides/output/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  178. data/guides/output/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  179. data/guides/output/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  180. data/guides/output/testing.html +0 -1182
@@ -1,662 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
-
8
- <title>Ruby on Rails Guides: A Guide to The Rails Command Line</title>
9
-
10
- <link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
11
- <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
12
-
13
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" />
14
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" />
15
-
16
- <link rel="stylesheet" type="text/css" href="stylesheets/fixes.css" />
17
- </head>
18
- <body class="guide">
19
- <div id="topNav">
20
- <div class="wrapper">
21
- <strong>More at <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong>
22
- <a href="http://rubyonrails.org/">Overview</a> |
23
- <a href="http://rubyonrails.org/download">Download</a> |
24
- <a href="http://rubyonrails.org/deploy">Deploy</a> |
25
- <a href="https://github.com/rails/rails">Code</a> |
26
- <a href="http://rubyonrails.org/screencasts">Screencasts</a> |
27
- <a href="http://rubyonrails.org/documentation">Documentation</a> |
28
- <a href="http://rubyonrails.org/ecosystem">Ecosystem</a> |
29
- <a href="http://rubyonrails.org/community">Community</a> |
30
- <a href="http://weblog.rubyonrails.org/">Blog</a>
31
- </div>
32
- </div>
33
- <div id="header">
34
- <div class="wrapper clearfix">
35
- <h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
36
- <p class="hide"><a href="#mainCol">Skip navigation</a>.</p>
37
- <ul class="nav">
38
- <li><a href="index.html">Home</a></li>
39
- <li class="index"><a href="index.html" onclick="guideMenu(); return false;" id="guidesMenu">Guides Index</a>
40
- <div id="guides" class="clearfix" style="display: none;">
41
- <hr />
42
- <dl class="L">
43
- <dt>Start Here</dt>
44
- <dd><a href="getting_started.html">Getting Started with Rails</a></dd>
45
- <dt>Models</dt>
46
- <dd><a href="migrations.html">Rails Database Migrations</a></dd>
47
- <dd><a href="active_record_validations_callbacks.html">Active Record Validations and Callbacks</a></dd>
48
- <dd><a href="association_basics.html">Active Record Associations</a></dd>
49
- <dd><a href="active_record_querying.html">Active Record Query Interface</a></dd>
50
- <dt>Views</dt>
51
- <dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd>
52
- <dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
53
- <dt>Controllers</dt>
54
- <dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
55
- <dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
56
- </dl>
57
- <dl class="R">
58
- <dt>Digging Deeper</dt>
59
- <dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
60
- <dd><a href="i18n.html">Rails Internationalization API</a></dd>
61
- <dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
62
- <dd><a href="testing.html">Testing Rails Applications</a></dd>
63
- <dd><a href="security.html">Securing Rails Applications</a></dd>
64
- <dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
65
- <dd><a href="performance_testing.html">Performance Testing Rails Applications</a></dd>
66
- <dd><a href="configuring.html">Configuring Rails Applications</a></dd>
67
- <dd><a href="command_line.html">Rails Command Line Tools and Rake Tasks</a></dd>
68
- <dd><a href="caching_with_rails.html">Caching with Rails</a></dd>
69
- <dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
70
-
71
- <dt>Extending Rails</dt>
72
- <dd><a href="plugins.html">The Basics of Creating Rails Plugins</a></dd>
73
- <dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
74
- <dd><a href="generators.html">Creating and Customizing Rails Generators</a></dd>
75
-
76
- <dt>Contributing to Ruby on Rails</dt>
77
- <dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
78
- <dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
79
- <dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
80
-
81
- <dt>Release Notes</dt>
82
- <dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
83
- <dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
84
- <dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
85
- <dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
86
- </dl>
87
- </div>
88
- </li>
89
- <li><a href="contributing_to_ruby_on_rails.html">Contribute</a></li>
90
- <li><a href="credits.html">Credits</a></li>
91
- </ul>
92
- </div>
93
- </div>
94
- <hr class="hide" />
95
-
96
- <div id="feature">
97
- <div class="wrapper">
98
- <h2>A Guide to The Rails Command Line</h2>
99
- <p>Rails comes with every command line tool you&#8217;ll need to</p>
100
- <ul>
101
- <li>Create a Rails application</li>
102
- <li>Generate models, controllers, database migrations, and unit tests</li>
103
- <li>Start a development server</li>
104
- <li>Experiment with objects through an interactive shell</li>
105
- <li>Profile and benchmark your new creation</li>
106
- </ul>
107
-
108
- <div id="subCol">
109
- <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
110
- <ol class="chapters">
111
- <li><a href="#command-line-basics">Command Line Basics</a><ul><li><a href="#rails-new"><tt>rails new</tt></a></li> <li><a href="#rails-server"><tt>rails server</tt></a></li> <li><a href="#rails-generate"><tt>rails generate</tt></a></li> <li><a href="#rails-console"><tt>rails console</tt></a></li> <li><a href="#rails-dbconsole"><tt>rails dbconsole</tt></a></li> <li><a href="#rails-plugin"><tt>rails plugin</tt></a></li> <li><a href="#rails-runner"><tt>rails runner</tt></a></li> <li><a href="#rails-destroy"><tt>rails destroy</tt></a></li></ul></li><li><a href="#rake">Rake</a><ul><li><a href="#about"><tt>about</tt></a></li> <li><a href="#assets"><tt>assets</tt></a></li> <li><a href="#db"><tt>db</tt></a></li> <li><a href="#doc"><tt>doc</tt></a></li> <li><a href="#notes"><tt>notes</tt></a></li> <li><a href="#routes"><tt>routes</tt></a></li> <li><a href="#test"><tt>test</tt></a></li> <li><a href="#tmp"><tt>tmp</tt></a></li> <li><a href="#miscellaneous">Miscellaneous</a></li></ul></li><li><a href="#the-rails-advanced-command-line">The Rails Advanced Command Line</a><ul><li><a href="#rails-with-databases-and-scm">Rails with Databases and <span class="caps">SCM</span></a></li> <li><a href="#different-servers"><tt>server</tt> with Different Backends</a></li></ul></li></ol></div>
112
- </div>
113
- </div>
114
-
115
- <div id="container">
116
- <div class="wrapper">
117
- <div id="mainCol">
118
- <div class="note"><p>This tutorial assumes you have basic Rails knowledge from reading the <a href="getting_started.html">Getting Started with Rails Guide</a>.</p></div>
119
- <div class="warning"><p>This Guide is based on Rails 3.0. Some of the code shown here will not work in earlier versions of Rails.</p></div>
120
- <h3 id="command-line-basics">1 Command Line Basics</h3>
121
- <p>There are a few commands that are absolutely critical to your everyday usage of Rails. In the order of how much you&#8217;ll probably use them are:</p>
122
- <ul>
123
- <li><tt>rails console</tt></li>
124
- <li><tt>rails server</tt></li>
125
- <li><tt>rake</tt></li>
126
- <li><tt>rails generate</tt></li>
127
- <li><tt>rails dbconsole</tt></li>
128
- <li><tt>rails new app_name</tt></li>
129
- </ul>
130
- <p>Let&#8217;s create a simple Rails application to step through each of these commands in context.</p>
131
- <h4 id="rails-new">1.1 <tt>rails new</tt></h4>
132
- <p>The first thing we&#8217;ll want to do is create a new Rails application by running the <tt>rails new</tt> command after installing Rails.</p>
133
- <div class="warning"><p>You can install the rails gem by typing <tt>gem install rails</tt>, if you don&#8217;t have it already. Follow the instructions in the <a href="/3_0_release_notes.html">Rails 3 Release Notes</a></p></div>
134
- <div class="code_container">
135
- <pre class="brush: plain; gutter: false; toolbar: false">
136
- $ rails new commandsapp
137
- create
138
- create README
139
- create .gitignore
140
- create Rakefile
141
- create config.ru
142
- create Gemfile
143
- create app
144
- ...
145
- create tmp/cache
146
- create tmp/pids
147
- create vendor/plugins
148
- create vendor/plugins/.gitkeep
149
- </pre>
150
- </div>
151
- <p>Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You&#8217;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>
152
- <h4 id="rails-server">1.2 <tt>rails server</tt></h4>
153
- <p>The <tt>rails server</tt> command launches a small web server named WEBrick which comes bundled with Ruby. You&#8217;ll use this any time you want to access your application through a web browser.</p>
154
- <div class="info"><p>WEBrick isn&#8217;t your only option for serving Rails. We&#8217;ll get to that <a href="#different-servers">later</a>.</p></div>
155
- <p>With no further work, <tt>rails server</tt> will run our new shiny Rails app:</p>
156
- <div class="code_container">
157
- <pre class="brush: plain; gutter: false; toolbar: false">
158
- $ cd commandsapp
159
- $ rails server
160
- =&gt; Booting WEBrick
161
- =&gt; Rails 3.1.0 application starting in development on http://0.0.0.0:3000
162
- =&gt; Call with -d to detach
163
- =&gt; Ctrl-C to shutdown server
164
- [2010-04-18 03:20:33] INFO WEBrick 1.3.1
165
- [2010-04-18 03:20:33] INFO ruby 1.8.7 (2010-01-10) [x86_64-linux]
166
- [2010-04-18 03:20:33] INFO WEBrick::HTTPServer#start: pid=26086 port=3000
167
- </pre>
168
- </div>
169
- <p>With just three commands we whipped up a Rails server listening on port 3000. Go to your browser and open <a href="http://localhost:3000">http://localhost:3000</a>, you will see a basic Rails app running.</p>
170
- <p>You can also use the alias &#8220;s&#8221; to start the server: <tt>rails s</tt>.</p>
171
- <p>The server can be run on a different port using the <tt>-p</tt> option. The default development environment can be changed using <tt>-e</tt>.</p>
172
- <div class="code_container">
173
- <pre class="brush: plain; gutter: false; toolbar: false">
174
- $ rails server -e production -p 4000
175
- </pre>
176
- </div>
177
- <h4 id="rails-generate">1.3 <tt>rails generate</tt></h4>
178
- <p>The <tt>rails generate</tt> command uses templates to create a whole lot of things. Running <tt>rails generate</tt> by itself gives a list of available generators:</p>
179
- <p>You can also use the alias &#8220;g&#8221; to invoke the generator command: <tt>rails g</tt>.</p>
180
- <div class="code_container">
181
- <pre class="brush: plain; gutter: false; toolbar: false">
182
- $ rails generate
183
- Usage: rails generate GENERATOR [args] [options]
184
-
185
- ...
186
- ...
187
-
188
- Please choose a generator below.
189
-
190
- Rails:
191
- controller
192
- generator
193
- ...
194
- ...
195
- </pre>
196
- </div>
197
- <div class="note"><p>You can install more generators through generator gems, portions of plugins you&#8217;ll undoubtedly install, and you can even create your own!</p></div>
198
- <p>Using generators will save you a large amount of time by writing <strong>boilerplate code</strong>, code that is necessary for the app to work.</p>
199
- <p>Let&#8217;s make our own controller with the controller generator. But what command should we use? Let&#8217;s ask the generator:</p>
200
- <div class="info"><p>All Rails console utilities have help text. As with most *nix utilities, you can try adding <tt>--help</tt> or <tt>-h</tt> to the end, for example <tt>rails server --help</tt>.</p></div>
201
- <div class="code_container">
202
- <pre class="brush: plain; gutter: false; toolbar: false">
203
- $ rails generate controller
204
- Usage: rails generate controller NAME [action action] [options]
205
-
206
- ...
207
- ...
208
-
209
- Example:
210
- rails generate controller CreditCard open debit credit close
211
-
212
- Credit card controller with URLs like /credit_card/debit.
213
- Controller: app/controllers/credit_card_controller.rb
214
- Views: app/views/credit_card/debit.html.erb [...]
215
- Helper: app/helpers/credit_card_helper.rb
216
- Test: test/functional/credit_card_controller_test.rb
217
-
218
- Modules Example:
219
- rails generate controller 'admin/credit_card' suspend late_fee
220
-
221
- Credit card admin controller with URLs like /admin/credit_card/suspend.
222
- Controller: app/controllers/admin/credit_card_controller.rb
223
- Views: app/views/admin/credit_card/debit.html.erb [...]
224
- Helper: app/helpers/admin/credit_card_helper.rb
225
- Test: test/functional/admin/credit_card_controller_test.rb
226
- </pre>
227
- </div>
228
- <p>The controller generator is expecting parameters in the form of <tt>generate controller ControllerName action1 action2</tt>. Let&#8217;s make a <tt>Greetings</tt> controller with an action of <strong>hello</strong>, which will say something nice to us.</p>
229
- <div class="code_container">
230
- <pre class="brush: plain; gutter: false; toolbar: false">
231
- $ rails generate controller Greetings hello
232
- create app/controllers/greetings_controller.rb
233
- route get &quot;greetings/hello&quot;
234
- invoke erb
235
- create app/views/greetings
236
- create app/views/greetings/hello.html.erb
237
- invoke test_unit
238
- create test/functional/greetings_controller_test.rb
239
- invoke helper
240
- create app/helpers/greetings_helper.rb
241
- invoke test_unit
242
- create test/unit/helpers/greetings_helper_test.rb
243
- invoke assets
244
- create app/assets/javascripts/greetings.js
245
- invoke css
246
- create app/assets/stylesheets/greetings.css
247
- </pre>
248
- </div>
249
- <p>What all did this generate? It made sure a bunch of directories were in our application, and created a controller file, a view file, a functional test file, a helper for the view, a javascript file and a stylesheet file.</p>
250
- <p>Check out the controller and modify it a little (in <tt>app/controllers/greetings_controller.rb</tt>):</p>
251
- <div class="code_container">
252
- <pre class="brush: ruby; gutter: false; toolbar: false">
253
- class GreetingsController &lt; ApplicationController
254
- def hello
255
- @message = &quot;Hello, how are you today?&quot;
256
- end
257
- end
258
- </pre>
259
- </div>
260
- <p>Then the view, to display our message (in <tt>app/views/greetings/hello.html.erb</tt>):</p>
261
- <div class="code_container">
262
- <pre class="brush: xml; gutter: false; toolbar: false">
263
- &lt;h1&gt;A Greeting for You!&lt;/h1&gt;
264
- &lt;p&gt;&lt;%= @message %&gt;&lt;/p&gt;
265
- </pre>
266
- </div>
267
- <p>Fire up your server using <tt>rails server</tt>.</p>
268
- <div class="code_container">
269
- <pre class="brush: plain; gutter: false; toolbar: false">
270
- $ rails server
271
- =&gt; Booting WEBrick...
272
- </pre>
273
- </div>
274
- <div class="warning"><p>Make sure that you do not have any &#8220;tilde backup&#8221; files in <tt>app/views/(controller)</tt>, or else WEBrick will <em>not</em> show the expected output. This seems to be a <strong>bug</strong> in Rails 2.3.0.</p></div>
275
- <p>The <span class="caps">URL</span> will be <a href="http://localhost:3000/greetings/hello">http://localhost:3000/greetings/hello</a>.</p>
276
- <div class="info"><p>With a normal, plain-old Rails application, your URLs will generally follow the pattern of http://(host)/(controller)/(action), and a <span class="caps">URL</span> like http://(host)/(controller) will hit the <strong>index</strong> action of that controller.</p></div>
277
- <p>Rails comes with a generator for data models too.</p>
278
- <div class="code_container">
279
- <pre class="brush: plain; gutter: false; toolbar: false">
280
- $ rails generate model
281
- Usage: rails generate model NAME [field:type field:type] [options]
282
-
283
- ...
284
-
285
- Examples:
286
- rails generate model account
287
-
288
- Model: app/models/account.rb
289
- Test: test/unit/account_test.rb
290
- Fixtures: test/fixtures/accounts.yml
291
- Migration: db/migrate/XXX_add_accounts.rb
292
-
293
- rails generate model post title:string body:text published:boolean
294
-
295
- Creates a Post model with a string title, text body, and published flag.
296
- </pre>
297
- </div>
298
- <div class="note"><p>For a list of available field types, refer to the <a href="http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column"><span class="caps">API</span> documentation</a> for the column method for the <tt>TableDefinition</tt> class.</p></div>
299
- <p>But instead of generating a model directly (which we&#8217;ll be doing later), let&#8217;s set up a scaffold. A <strong>scaffold</strong> in Rails is a full set of model, database migration for that model, controller to manipulate it, views to view and manipulate the data, and a test suite for each of the above.</p>
300
- <p>We will set up a simple resource called &#8220;HighScore&#8221; that will keep track of our highest score on video games we play.</p>
301
- <div class="code_container">
302
- <pre class="brush: plain; gutter: false; toolbar: false">
303
- $ rails generate scaffold HighScore game:string score:integer
304
- exists app/models/
305
- exists app/controllers/
306
- exists app/helpers/
307
- create app/views/high_scores
308
- create app/views/layouts/
309
- exists test/functional/
310
- create test/unit/
311
- create app/assets/stylesheets/
312
- create app/views/high_scores/index.html.erb
313
- create app/views/high_scores/show.html.erb
314
- create app/views/high_scores/new.html.erb
315
- create app/views/high_scores/edit.html.erb
316
- create app/views/layouts/high_scores.html.erb
317
- create app/assets/stylesheets/scaffold.css.scss
318
- create app/controllers/high_scores_controller.rb
319
- create test/functional/high_scores_controller_test.rb
320
- create app/helpers/high_scores_helper.rb
321
- route resources :high_scores
322
- dependency model
323
- exists app/models/
324
- exists test/unit/
325
- create test/fixtures/
326
- create app/models/high_score.rb
327
- create test/unit/high_score_test.rb
328
- create test/fixtures/high_scores.yml
329
- exists db/migrate
330
- create db/migrate/20100209025147_create_high_scores.rb
331
- </pre>
332
- </div>
333
- <p>The generator checks that there exist the directories for models, controllers, helpers, layouts, functional and unit tests, stylesheets, creates the views, controller, model and database migration for HighScore (creating the <tt>high_scores</tt> table and fields), takes care of the route for the <strong>resource</strong>, and new tests for everything.</p>
334
- <p>The migration requires that we <strong>migrate</strong>, that is, run some Ruby code (living in that <tt>20100209025147_create_high_scores.rb</tt>) to modify the schema of our database. Which database? The sqlite3 database that Rails will create for you when we run the <tt>rake db:migrate</tt> command. We&#8217;ll talk more about Rake in-depth in a little while.</p>
335
- <div class="code_container">
336
- <pre class="brush: plain; gutter: false; toolbar: false">
337
- $ rake db:migrate
338
- (in /home/foobar/commandsapp)
339
- == CreateHighScores: migrating ===============================================
340
- -- create_table(:high_scores)
341
- -&gt; 0.0026s
342
- == CreateHighScores: migrated (0.0028s) ======================================
343
- </pre>
344
- </div>
345
- <div class="info"><p>Let&#8217;s talk about unit tests. Unit tests are code that tests and makes assertions about code. In unit testing, we take a little part of code, say a method of a model, and test its inputs and outputs. Unit tests are your friend. The sooner you make peace with the fact that your quality of life will drastically increase when you unit test your code, the better. Seriously. We&#8217;ll make one in a moment.</p></div>
346
- <p>Let&#8217;s see the interface Rails created for us.</p>
347
- <div class="code_container">
348
- <pre class="brush: plain; gutter: false; toolbar: false">
349
- $ rails server
350
- </pre>
351
- </div>
352
- <p>Go to your browser and open <a href="http://localhost:3000/high_scores">http://localhost:3000/high_scores</a>, now we can create new high scores (55,160 on Space Invaders!)</p>
353
- <h4 id="rails-console">1.4 <tt>rails console</tt></h4>
354
- <p>The <tt>console</tt> command lets you interact with your Rails application from the command line. On the underside, <tt>rails console</tt> uses <span class="caps">IRB</span>, so if you&#8217;ve ever used it, you&#8217;ll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.</p>
355
- <p>You can also use the alias &#8220;c&#8221; to invoke the console: <tt>rails c</tt>.</p>
356
- <p>If you wish to test out some code without changing any data, you can do that by invoking <tt>rails console --sandbox</tt>.</p>
357
- <div class="code_container">
358
- <pre class="brush: plain; gutter: false; toolbar: false">
359
- $ rails console --sandbox
360
- Loading development environment in sandbox (Rails 3.1.0)
361
- Any modifications you make will be rolled back on exit
362
- irb(main):001:0&gt;
363
- </pre>
364
- </div>
365
- <h4 id="rails-dbconsole">1.5 <tt>rails dbconsole</tt></h4>
366
- <p><tt>rails dbconsole</tt> figures out which database you&#8217;re using and drops you into whichever command line interface you would use with it (and figures out the command line parameters to give to it, too!). It supports MySQL, PostgreSQL, SQLite and SQLite3.</p>
367
- <p>You can also use the alias &#8220;db&#8221; to invoke the dbconsole: <tt>rails db</tt>.</p>
368
- <h4 id="rails-plugin">1.6 <tt>rails plugin</tt></h4>
369
- <p>The <tt>rails plugin</tt> command simplifies plugin management. Plugins can be installed by name or their repository URLs. You need to have Git installed if you want to install a plugin from a Git repo. The same holds for Subversion too.</p>
370
- <div class="code_container">
371
- <pre class="brush: plain; gutter: false; toolbar: false">
372
- $ rails plugin install https://github.com/technoweenie/acts_as_paranoid.git
373
- + ./CHANGELOG
374
- + ./MIT-LICENSE
375
- ...
376
- ...
377
- </pre>
378
- </div>
379
- <h4 id="rails-runner">1.7 <tt>rails runner</tt></h4>
380
- <p><tt>runner</tt> runs Ruby code in the context of Rails non-interactively. For instance:</p>
381
- <div class="code_container">
382
- <pre class="brush: plain; gutter: false; toolbar: false">
383
- $ rails runner &quot;Model.long_running_method&quot;
384
- </pre>
385
- </div>
386
- <p>You can also use the alias &#8220;r&#8221; to invoke the runner: <tt>rails r</tt>.</p>
387
- <p>You can specify the environment in which the <tt>runner</tt> command should operate using the <tt>-e</tt> switch.</p>
388
- <div class="code_container">
389
- <pre class="brush: plain; gutter: false; toolbar: false">
390
- $ rails runner -e staging &quot;Model.long_running_method&quot;
391
- </pre>
392
- </div>
393
- <h4 id="rails-destroy">1.8 <tt>rails destroy</tt></h4>
394
- <p>Think of <tt>destroy</tt> as the opposite of <tt>generate</tt>. It&#8217;ll figure out what generate did, and undo it.</p>
395
- <p>You can also use the alias &#8220;d&#8221; to invoke the destroy command: <tt>rails d</tt>.</p>
396
- <div class="code_container">
397
- <pre class="brush: plain; gutter: false; toolbar: false">
398
- $ rails generate model Oops
399
- exists app/models/
400
- exists test/unit/
401
- exists test/fixtures/
402
- create app/models/oops.rb
403
- create test/unit/oops_test.rb
404
- create test/fixtures/oops.yml
405
- exists db/migrate
406
- create db/migrate/20081221040817_create_oops.rb
407
- $ rails destroy model Oops
408
- notempty db/migrate
409
- notempty db
410
- rm db/migrate/20081221040817_create_oops.rb
411
- rm test/fixtures/oops.yml
412
- rm test/unit/oops_test.rb
413
- rm app/models/oops.rb
414
- notempty test/fixtures
415
- notempty test
416
- notempty test/unit
417
- notempty test
418
- notempty app/models
419
- notempty app
420
- </pre>
421
- </div>
422
- <h3 id="rake">2 Rake</h3>
423
- <p>Rake is Ruby Make, a standalone Ruby utility that replaces the Unix utility &#8216;make&#8217;, and uses a &#8216;Rakefile&#8217; and <tt>.rake</tt> files to build up a list of tasks. In Rails, Rake is used for common administration tasks, especially sophisticated ones that build off of each other.</p>
424
- <p>You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing <tt>rake --tasks</tt>. Each task has a description, and should help you find the thing you need.</p>
425
- <div class="code_container">
426
- <pre class="brush: plain; gutter: false; toolbar: false">
427
- $ rake --tasks
428
- (in /home/foobar/commandsapp)
429
- rake db:abort_if_pending_migrations # Raises an error if there are pending migrations
430
- rake db:charset # Retrieves the charset for the current environment's database
431
- rake db:collation # Retrieves the collation for the current environment's database
432
- rake db:create # Create the database defined in config/database.yml for the current Rails.env
433
- ...
434
- ...
435
- rake tmp:pids:clear # Clears all files in tmp/pids
436
- rake tmp:sessions:clear # Clears all files in tmp/sessions
437
- rake tmp:sockets:clear # Clears all files in tmp/sockets
438
- </pre>
439
- </div>
440
- <h4 id="about">2.1 <tt>about</tt></h4>
441
- <p><tt>rake about</tt> gives information about version numbers for Ruby, RubyGems, Rails, the Rails subcomponents, your application&#8217;s folder, the current Rails environment name, your app&#8217;s database adapter, and schema version. It is useful when you need to ask for help, check if a security patch might affect you, or when you need some stats for an existing Rails installation.</p>
442
- <div class="code_container">
443
- <pre class="brush: plain; gutter: false; toolbar: false">
444
- $ rake about
445
- About your application's environment
446
- Ruby version 1.8.7 (x86_64-linux)
447
- RubyGems version 1.3.6
448
- Rack version 1.3
449
- Rails version 3.2.0.beta
450
- JavaScript Runtime Node.js (V8)
451
- Active Record version 3.2.0.beta
452
- Action Pack version 3.2.0.beta
453
- Active Resource version 3.2.0.beta
454
- Action Mailer version 3.2.0.beta
455
- Active Support version 3.2.0.beta
456
- Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport
457
- Application root /home/foobar/commandsapp
458
- Environment development
459
- Database adapter sqlite3
460
- Database schema version 20110805173523
461
- </pre>
462
- </div>
463
- <h4 id="assets">2.2 <tt>assets</tt></h4>
464
- <p>You can precompile the assets in <tt>app/assets</tt> using <tt>rake assets:precompile</tt> and remove those compiled assets using <tt>rake assets:clean</tt>.</p>
465
- <h4 id="db">2.3 <tt>db</tt></h4>
466
- <p>The most common tasks of the <tt>db:</tt> Rake namespace are <tt>migrate</tt> and <tt>create</tt>, and it will pay off to try out all of the migration rake tasks (<tt>up</tt>, <tt>down</tt>, <tt>redo</tt>, <tt>reset</tt>). <tt>rake db:version</tt> is useful when troubleshooting, telling you the current version of the database.</p>
467
- <p>More information about migrations can be found in the <a href="migrations.html">Migrations</a> guide.</p>
468
- <h4 id="doc">2.4 <tt>doc</tt></h4>
469
- <p>The <tt>doc:</tt> namespace has the tools to generate documentation for your app, <span class="caps">API</span> documentation, guides. Documentation can also be stripped which is mainly useful for slimming your codebase, like if you&#8217;re writing a Rails application for an embedded platform.</p>
470
- <ul>
471
- <li><tt>rake doc:app</tt> generates documentation for your application in <tt>doc/app</tt>.</li>
472
- <li><tt>rake doc:guides</tt> generates Rails guides in <tt>doc/guides</tt>.</li>
473
- <li><tt>rake doc:rails</tt> generates <span class="caps">API</span> documentation for Rails in <tt>doc/api</tt>.</li>
474
- <li><tt>rake doc:plugins</tt> generates <span class="caps">API</span> documentation for all the plugins installed in the application in <tt>doc/plugins</tt>.</li>
475
- <li><tt>rake doc:clobber_plugins</tt> removes the generated documentation for all plugins.</li>
476
- </ul>
477
- <h4 id="notes">2.5 <tt>notes</tt></h4>
478
- <p><tt>rake notes</tt> will search through your code for comments beginning with <span class="caps">FIXME</span>, <span class="caps">OPTIMIZE</span> or <span class="caps">TODO</span>. The search is only done in files with extension <tt>.builder</tt>, <tt>.rb</tt>, <tt>.rxml</tt>, <tt>.rhtml</tt> and <tt>.erb</tt> for both default and custom annotations.</p>
479
- <div class="code_container">
480
- <pre class="brush: plain; gutter: false; toolbar: false">
481
- $ rake notes
482
- (in /home/foobar/commandsapp)
483
- app/controllers/admin/users_controller.rb:
484
- * [ 20] [TODO] any other way to do this?
485
- * [132] [FIXME] high priority for next deploy
486
-
487
- app/model/school.rb:
488
- * [ 13] [OPTIMIZE] refactor this code to make it faster
489
- * [ 17] [FIXME]
490
- </pre>
491
- </div>
492
- <p>If you are looking for a specific annotation, say <span class="caps">FIXME</span>, you can use <tt>rake notes:fixme</tt>. Note that you have to lower case the annotation&#8217;s name.</p>
493
- <div class="code_container">
494
- <pre class="brush: plain; gutter: false; toolbar: false">
495
- $ rake notes:fixme
496
- (in /home/foobar/commandsapp)
497
- app/controllers/admin/users_controller.rb:
498
- * [132] high priority for next deploy
499
-
500
- app/model/school.rb:
501
- * [ 17]
502
- </pre>
503
- </div>
504
- <p>You can also use custom annotations in your code and list them using <tt>rake notes:custom</tt> by specifying the annotation using an environment variable <tt>ANNOTATION</tt>.</p>
505
- <div class="code_container">
506
- <pre class="brush: plain; gutter: false; toolbar: false">
507
- $ rake notes:custom ANNOTATION=BUG
508
- (in /home/foobar/commandsapp)
509
- app/model/post.rb:
510
- * [ 23] Have to fix this one before pushing!
511
- </pre>
512
- </div>
513
- <div class="note"><p>When using specific annotations and custom annotations, the annotation name (<span class="caps">FIXME</span>, <span class="caps">BUG</span> etc) is not displayed in the output lines.</p></div>
514
- <h4 id="routes">2.6 <tt>routes</tt></h4>
515
- <p><tt>rake routes</tt> will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you&#8217;re trying to get familiar with.</p>
516
- <h4 id="test">2.7 <tt>test</tt></h4>
517
- <div class="info"><p>A good description of unit testing in Rails is given in <a href="testing.html">A Guide to Testing Rails Applications</a></p></div>
518
- <p>Rails comes with a test suite called <tt>Test::Unit</tt>. Rails owes its stability to the use of tests. The tasks available in the <tt>test:</tt> namespace helps in running the different tests you will hopefully write.</p>
519
- <h4 id="tmp">2.8 <tt>tmp</tt></h4>
520
- <p>The <tt>Rails.root/tmp</tt> directory is, like the *nix /tmp directory, the holding place for temporary files like sessions (if you&#8217;re using a file store for files), process id files, and cached actions.</p>
521
- <p>The <tt>tmp:</tt> namespaced tasks will help you clear the <tt>Rails.root/tmp</tt> directory:</p>
522
- <ul>
523
- <li><tt>rake tmp:cache:clear</tt> clears <tt>tmp/cache</tt>.</li>
524
- <li><tt>rake tmp:sessions:clear</tt> clears <tt>tmp/sessions</tt>.</li>
525
- <li><tt>rake tmp:sockets:clear</tt> clears <tt>tmp/sockets</tt>.</li>
526
- <li><tt>rake tmp:clear</tt> clears all the three: cache, sessions and sockets.</li>
527
- </ul>
528
- <h4 id="miscellaneous">2.9 Miscellaneous</h4>
529
- <ul>
530
- <li><tt>rake stats</tt> is great for looking at statistics on your code, displaying things like KLOCs (thousands of lines of code) and your code to test ratio.</li>
531
- <li><tt>rake secret</tt> will give you a pseudo-random key to use for your session secret.</li>
532
- <li><tt>rake time:zones:all</tt> lists all the timezones Rails knows about.</li>
533
- </ul>
534
- <h3 id="the-rails-advanced-command-line">3 The Rails Advanced Command Line</h3>
535
- <p>More advanced use of the command line is focused around finding useful (even surprising at times) options in the utilities, and fitting those to your needs and specific work flow. Listed here are some tricks up Rails&#8217; sleeve.</p>
536
- <h4 id="rails-with-databases-and-scm">3.1 Rails with Databases and <span class="caps">SCM</span></h4>
537
- <p>When creating a new Rails application, you have the option to specify what kind of database and what kind of source code management system your application is going to use. This will save you a few minutes, and certainly many keystrokes.</p>
538
- <p>Let&#8217;s see what a <tt>--git</tt> option and a <tt>--database=postgresql</tt> option will do for us:</p>
539
- <div class="code_container">
540
- <pre class="brush: plain; gutter: false; toolbar: false">
541
- $ mkdir gitapp
542
- $ cd gitapp
543
- $ git init
544
- Initialized empty Git repository in .git/
545
- $ rails new . --git --database=postgresql
546
- exists
547
- create app/controllers
548
- create app/helpers
549
- ...
550
- ...
551
- create tmp/cache
552
- create tmp/pids
553
- create Rakefile
554
- add 'Rakefile'
555
- create README
556
- add 'README'
557
- create app/controllers/application_controller.rb
558
- add 'app/controllers/application_controller.rb'
559
- create app/helpers/application_helper.rb
560
- ...
561
- create log/test.log
562
- add 'log/test.log'
563
- </pre>
564
- </div>
565
- <p>We had to create the <strong>gitapp</strong> directory and initialize an empty git repository before Rails would add files it created to our repository. Let&#8217;s see what it put in our database configuration:</p>
566
- <div class="code_container">
567
- <pre class="brush: plain; gutter: false; toolbar: false">
568
- $ cat config/database.yml
569
- # PostgreSQL. Versions 8.2 and up are supported.
570
- #
571
- # Install the ruby-postgres driver:
572
- # gem install ruby-postgres
573
- # On Mac OS X:
574
- # gem install ruby-postgres -- --include=/usr/local/pgsql
575
- # On Windows:
576
- # gem install ruby-postgres
577
- # Choose the win32 build.
578
- # Install PostgreSQL and put its /bin directory on your path.
579
- development:
580
- adapter: postgresql
581
- encoding: unicode
582
- database: gitapp_development
583
- pool: 5
584
- username: gitapp
585
- password:
586
- ...
587
- ...
588
- </pre>
589
- </div>
590
- <p>It also generated some lines in our database.yml configuration corresponding to our choice of PostgreSQL for database.</p>
591
- <div class="note"><p>The only catch with using the <span class="caps">SCM</span> options is that you have to make your application&#8217;s directory first, then initialize your <span class="caps">SCM</span>, then you can run the <tt>rails new</tt> command to generate the basis of your app.</p></div>
592
- <h4 id="different-servers">3.2 <tt>server</tt> with Different Backends</h4>
593
- <p>Many people have created a large number of different web servers in Ruby, and many of them can be used to run Rails. Since version 2.3, Rails uses Rack to serve its webpages, which means that any webserver that implements a Rack handler can be used. This includes WEBrick, Mongrel, Thin, and Phusion Passenger (to name a few!).</p>
594
- <div class="note"><p>For more details on the Rack integration, see <a href="rails_on_rack.html">Rails on Rack</a>.</p></div>
595
- <p>To use a different server, just install its gem, then use its name for the first parameter to <tt>rails server</tt>:</p>
596
- <div class="code_container">
597
- <pre class="brush: plain; gutter: false; toolbar: false">
598
- $ sudo gem install mongrel
599
- Building native extensions. This could take a while...
600
- Building native extensions. This could take a while...
601
- Successfully installed gem_plugin-0.2.3
602
- Successfully installed fastthread-1.0.1
603
- Successfully installed cgi_multipart_eof_fix-2.5.0
604
- Successfully installed mongrel-1.1.5
605
- ...
606
- ...
607
- Installing RDoc documentation for mongrel-1.1.5...
608
- $ rails server mongrel
609
- =&gt; Booting Mongrel (use 'rails server webrick' to force WEBrick)
610
- =&gt; Rails 3.1.0 application starting on http://0.0.0.0:3000
611
- ...
612
- </pre>
613
- </div>
614
-
615
- <h3>Feedback</h3>
616
- <p>
617
- You're encouraged to help improve the quality of this guide.
618
- </p>
619
- <p>
620
- If you see any typos or factual errors you are confident to
621
- patch, please clone <a href="https://github.com/lifo/docrails">docrails</a>
622
- and push the change yourself. That branch of Rails has public write access.
623
- Commits are still reviewed, but that happens after you've submitted your
624
- contribution. <a href="https://github.com/lifo/docrails">docrails</a> is
625
- cross-merged with master periodically.
626
- </p>
627
- <p>
628
- You may also find incomplete content, or stuff that is not up to date.
629
- Please do add any missing documentation for master. Check the
630
- <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
631
- for style and conventions.
632
- </p>
633
- <p>
634
- If for whatever reason you spot something to fix but cannot patch it yourself, please
635
- <a href="https://github.com/rails/rails/issues">open an issue</a>.
636
- </p>
637
- <p>And last but not least, any kind of discussion regarding Ruby on Rails
638
- documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
639
- </p>
640
- </div>
641
- </div>
642
- </div>
643
-
644
- <hr class="hide" />
645
- <div id="footer">
646
- <div class="wrapper">
647
- <p>This work is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike 3.0</a> License</p>
648
- <p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
649
- </div>
650
- </div>
651
-
652
- <script type="text/javascript" src="javascripts/guides.js"></script>
653
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
654
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
655
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
656
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
657
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
658
- <script type="text/javascript">
659
- SyntaxHighlighter.all()
660
- </script>
661
- </body>
662
- </html>