rails 4.2.0.beta4 → 4.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/guides/Rakefile +3 -1
  3. data/guides/bug_report_templates/action_controller_gem.rb +2 -2
  4. data/guides/bug_report_templates/action_controller_master.rb +2 -2
  5. data/guides/source/3_0_release_notes.md +2 -2
  6. data/guides/source/4_1_release_notes.md +1 -1
  7. data/guides/source/4_2_release_notes.md +250 -225
  8. data/guides/source/_welcome.html.erb +1 -1
  9. data/guides/source/action_controller_overview.md +6 -6
  10. data/guides/source/action_mailer_basics.md +26 -11
  11. data/guides/source/action_view_overview.md +0 -1
  12. data/guides/source/active_job_basics.md +29 -23
  13. data/guides/source/active_record_postgresql.md +2 -7
  14. data/guides/source/active_record_validations.md +1 -0
  15. data/guides/source/active_support_core_extensions.md +1 -1
  16. data/guides/source/active_support_instrumentation.md +5 -5
  17. data/guides/source/asset_pipeline.md +2 -2
  18. data/guides/source/association_basics.md +0 -2
  19. data/guides/source/command_line.md +6 -15
  20. data/guides/source/configuring.md +4 -4
  21. data/guides/source/documents.yaml +0 -1
  22. data/guides/source/engines.md +26 -15
  23. data/guides/source/form_helpers.md +10 -2
  24. data/guides/source/getting_started.md +9 -9
  25. data/guides/source/rails_on_rack.md +2 -2
  26. data/guides/source/ruby_on_rails_guides_guidelines.md +1 -0
  27. data/guides/source/security.md +1 -1
  28. data/guides/source/testing.md +80 -13
  29. data/guides/source/upgrading_ruby_on_rails.md +23 -20
  30. metadata +29 -229
  31. data/guides/output/2_2_release_notes.html +0 -724
  32. data/guides/output/2_3_release_notes.html +0 -870
  33. data/guides/output/3_0_release_notes.html +0 -773
  34. data/guides/output/3_1_release_notes.html +0 -740
  35. data/guides/output/3_2_release_notes.html +0 -797
  36. data/guides/output/4_0_release_notes.html +0 -523
  37. data/guides/output/4_1_release_notes.html +0 -806
  38. data/guides/output/4_2_release_notes.html +0 -728
  39. data/guides/output/Gemfile +0 -6
  40. data/guides/output/_license.html +0 -226
  41. data/guides/output/_welcome.html +0 -233
  42. data/guides/output/action_controller_overview.html +0 -1335
  43. data/guides/output/action_mailer_basics.html +0 -928
  44. data/guides/output/action_view_overview.html +0 -1509
  45. data/guides/output/active_job_basics.html +0 -546
  46. data/guides/output/active_model_basics.html +0 -438
  47. data/guides/output/active_record_basics.html +0 -594
  48. data/guides/output/active_record_callbacks.html +0 -592
  49. data/guides/output/active_record_migrations.html +0 -1123
  50. data/guides/output/active_record_postgresql.html +0 -675
  51. data/guides/output/active_record_querying.html +0 -1796
  52. data/guides/output/active_record_validations.html +0 -1301
  53. data/guides/output/active_support_core_extensions.html +0 -3450
  54. data/guides/output/active_support_instrumentation.html +0 -1121
  55. data/guides/output/api_documentation_guidelines.html +0 -498
  56. data/guides/output/asset_pipeline.html +0 -1167
  57. data/guides/output/association_basics.html +0 -2086
  58. data/guides/output/caching_with_rails.html +0 -553
  59. data/guides/output/command_line.html +0 -791
  60. data/guides/output/configuring.html +0 -1055
  61. data/guides/output/contributing_to_ruby_on_rails.html +0 -657
  62. data/guides/output/credits.html +0 -284
  63. data/guides/output/debugging_rails_applications.html +0 -1014
  64. data/guides/output/development_dependencies_install.html +0 -478
  65. data/guides/output/engines.html +0 -1438
  66. data/guides/output/form_helpers.html +0 -1074
  67. data/guides/output/generators.html +0 -838
  68. data/guides/output/getting_started.html +0 -2092
  69. data/guides/output/i18n.html +0 -1198
  70. data/guides/output/images/akshaysurve.jpg +0 -0
  71. data/guides/output/images/belongs_to.png +0 -0
  72. data/guides/output/images/book_icon.gif +0 -0
  73. data/guides/output/images/bullet.gif +0 -0
  74. data/guides/output/images/chapters_icon.gif +0 -0
  75. data/guides/output/images/check_bullet.gif +0 -0
  76. data/guides/output/images/credits_pic_blank.gif +0 -0
  77. data/guides/output/images/csrf.png +0 -0
  78. data/guides/output/images/edge_badge.png +0 -0
  79. data/guides/output/images/favicon.ico +0 -0
  80. data/guides/output/images/feature_tile.gif +0 -0
  81. data/guides/output/images/footer_tile.gif +0 -0
  82. data/guides/output/images/fxn.png +0 -0
  83. data/guides/output/images/getting_started/article_with_comments.png +0 -0
  84. data/guides/output/images/getting_started/challenge.png +0 -0
  85. data/guides/output/images/getting_started/confirm_dialog.png +0 -0
  86. data/guides/output/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  87. data/guides/output/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
  88. data/guides/output/images/getting_started/form_with_errors.png +0 -0
  89. data/guides/output/images/getting_started/index_action_with_edit_link.png +0 -0
  90. data/guides/output/images/getting_started/new_article.png +0 -0
  91. data/guides/output/images/getting_started/new_post.png +0 -0
  92. data/guides/output/images/getting_started/post_with_comments.png +0 -0
  93. data/guides/output/images/getting_started/rails_welcome.png +0 -0
  94. data/guides/output/images/getting_started/routing_error_no_controller.png +0 -0
  95. data/guides/output/images/getting_started/routing_error_no_route_matches.png +0 -0
  96. data/guides/output/images/getting_started/show_action_for_articles.png +0 -0
  97. data/guides/output/images/getting_started/show_action_for_posts.png +0 -0
  98. data/guides/output/images/getting_started/template_is_missing_articles_new.png +0 -0
  99. data/guides/output/images/getting_started/template_is_missing_posts_new.png +0 -0
  100. data/guides/output/images/getting_started/undefined_method_post_path.png +0 -0
  101. data/guides/output/images/getting_started/unknown_action_create_for_articles.png +0 -0
  102. data/guides/output/images/getting_started/unknown_action_create_for_posts.png +0 -0
  103. data/guides/output/images/getting_started/unknown_action_new_for_articles.png +0 -0
  104. data/guides/output/images/getting_started/unknown_action_new_for_posts.png +0 -0
  105. data/guides/output/images/grey_bullet.gif +0 -0
  106. data/guides/output/images/habtm.png +0 -0
  107. data/guides/output/images/has_many.png +0 -0
  108. data/guides/output/images/has_many_through.png +0 -0
  109. data/guides/output/images/has_one.png +0 -0
  110. data/guides/output/images/has_one_through.png +0 -0
  111. data/guides/output/images/header_backdrop.png +0 -0
  112. data/guides/output/images/header_tile.gif +0 -0
  113. data/guides/output/images/i18n/demo_html_safe.png +0 -0
  114. data/guides/output/images/i18n/demo_localized_pirate.png +0 -0
  115. data/guides/output/images/i18n/demo_translated_en.png +0 -0
  116. data/guides/output/images/i18n/demo_translated_pirate.png +0 -0
  117. data/guides/output/images/i18n/demo_translation_missing.png +0 -0
  118. data/guides/output/images/i18n/demo_untranslated.png +0 -0
  119. data/guides/output/images/icons/README +0 -5
  120. data/guides/output/images/icons/callouts/1.png +0 -0
  121. data/guides/output/images/icons/callouts/10.png +0 -0
  122. data/guides/output/images/icons/callouts/11.png +0 -0
  123. data/guides/output/images/icons/callouts/12.png +0 -0
  124. data/guides/output/images/icons/callouts/13.png +0 -0
  125. data/guides/output/images/icons/callouts/14.png +0 -0
  126. data/guides/output/images/icons/callouts/15.png +0 -0
  127. data/guides/output/images/icons/callouts/2.png +0 -0
  128. data/guides/output/images/icons/callouts/3.png +0 -0
  129. data/guides/output/images/icons/callouts/4.png +0 -0
  130. data/guides/output/images/icons/callouts/5.png +0 -0
  131. data/guides/output/images/icons/callouts/6.png +0 -0
  132. data/guides/output/images/icons/callouts/7.png +0 -0
  133. data/guides/output/images/icons/callouts/8.png +0 -0
  134. data/guides/output/images/icons/callouts/9.png +0 -0
  135. data/guides/output/images/icons/caution.png +0 -0
  136. data/guides/output/images/icons/example.png +0 -0
  137. data/guides/output/images/icons/home.png +0 -0
  138. data/guides/output/images/icons/important.png +0 -0
  139. data/guides/output/images/icons/next.png +0 -0
  140. data/guides/output/images/icons/note.png +0 -0
  141. data/guides/output/images/icons/prev.png +0 -0
  142. data/guides/output/images/icons/tip.png +0 -0
  143. data/guides/output/images/icons/up.png +0 -0
  144. data/guides/output/images/icons/warning.png +0 -0
  145. data/guides/output/images/nav_arrow.gif +0 -0
  146. data/guides/output/images/oscardelben.jpg +0 -0
  147. data/guides/output/images/polymorphic.png +0 -0
  148. data/guides/output/images/radar.png +0 -0
  149. data/guides/output/images/rails4_features.png +0 -0
  150. data/guides/output/images/rails_guides_kindle_cover.jpg +0 -0
  151. data/guides/output/images/rails_guides_logo.gif +0 -0
  152. data/guides/output/images/rails_logo_remix.gif +0 -0
  153. data/guides/output/images/session_fixation.png +0 -0
  154. data/guides/output/images/tab_grey.gif +0 -0
  155. data/guides/output/images/tab_info.gif +0 -0
  156. data/guides/output/images/tab_note.gif +0 -0
  157. data/guides/output/images/tab_red.gif +0 -0
  158. data/guides/output/images/tab_yellow.gif +0 -0
  159. data/guides/output/images/tab_yellow.png +0 -0
  160. data/guides/output/images/vijaydev.jpg +0 -0
  161. data/guides/output/index.html +0 -354
  162. data/guides/output/initialization.html +0 -876
  163. data/guides/output/javascripts/guides.js +0 -59
  164. data/guides/output/javascripts/jquery.min.js +0 -4
  165. data/guides/output/javascripts/responsive-tables.js +0 -43
  166. data/guides/output/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  167. data/guides/output/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  168. data/guides/output/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  169. data/guides/output/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  170. data/guides/output/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  171. data/guides/output/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  172. data/guides/output/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  173. data/guides/output/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  174. data/guides/output/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  175. data/guides/output/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  176. data/guides/output/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  177. data/guides/output/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  178. data/guides/output/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  179. data/guides/output/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  180. data/guides/output/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  181. data/guides/output/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  182. data/guides/output/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  183. data/guides/output/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  184. data/guides/output/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  185. data/guides/output/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  186. data/guides/output/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  187. data/guides/output/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  188. data/guides/output/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  189. data/guides/output/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  190. data/guides/output/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  191. data/guides/output/javascripts/syntaxhighlighter/shCore.js +0 -17
  192. data/guides/output/layout.html +0 -448
  193. data/guides/output/layouts_and_rendering.html +0 -1541
  194. data/guides/output/maintenance_policy.html +0 -257
  195. data/guides/output/migrations.html +0 -1360
  196. data/guides/output/nested_model_forms.html +0 -412
  197. data/guides/output/plugins.html +0 -644
  198. data/guides/output/rails_application_templates.html +0 -450
  199. data/guides/output/rails_on_rack.html +0 -547
  200. data/guides/output/routing.html +0 -1631
  201. data/guides/output/ruby_on_rails_guides_guidelines.html +0 -329
  202. data/guides/output/security.html +0 -935
  203. data/guides/output/stylesheets/fixes.css +0 -16
  204. data/guides/output/stylesheets/kindle.css +0 -11
  205. data/guides/output/stylesheets/main.css +0 -713
  206. data/guides/output/stylesheets/print.css +0 -52
  207. data/guides/output/stylesheets/reset.css +0 -43
  208. data/guides/output/stylesheets/responsive-tables.css +0 -50
  209. data/guides/output/stylesheets/style.css +0 -13
  210. data/guides/output/stylesheets/syntaxhighlighter/shCore.css +0 -226
  211. data/guides/output/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  212. data/guides/output/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  213. data/guides/output/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  214. data/guides/output/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  215. data/guides/output/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  216. data/guides/output/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  217. data/guides/output/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  218. data/guides/output/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  219. data/guides/output/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  220. data/guides/output/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  221. data/guides/output/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  222. data/guides/output/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  223. data/guides/output/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  224. data/guides/output/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  225. data/guides/output/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  226. data/guides/output/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  227. data/guides/output/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  228. data/guides/output/testing.html +0 -1350
  229. data/guides/output/upgrading_ruby_on_rails.html +0 -1135
  230. data/guides/output/working_with_javascript_in_rails.html +0 -587
@@ -1,498 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
7
-
8
- <title>API Documentation Guidelines — Ruby on Rails Guides</title>
9
- <link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
10
- <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
11
-
12
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" />
13
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" />
14
-
15
- <link rel="stylesheet" type="text/css" href="stylesheets/fixes.css" />
16
-
17
- <link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
18
- </head>
19
- <body class="guide">
20
- <div id="topNav">
21
- <div class="wrapper">
22
- <strong class="more-info-label">More at <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong>
23
- <span class="red-button more-info-button">
24
- More Ruby on Rails
25
- </span>
26
- <ul class="more-info-links s-hidden">
27
- <li class="more-info"><a href="http://rubyonrails.org/">Overview</a></li>
28
- <li class="more-info"><a href="http://rubyonrails.org/download">Download</a></li>
29
- <li class="more-info"><a href="http://rubyonrails.org/deploy">Deploy</a></li>
30
- <li class="more-info"><a href="https://github.com/rails/rails">Code</a></li>
31
- <li class="more-info"><a href="http://rubyonrails.org/screencasts">Screencasts</a></li>
32
- <li class="more-info"><a href="http://rubyonrails.org/documentation">Documentation</a></li>
33
- <li class="more-info"><a href="http://rubyonrails.org/community">Community</a></li>
34
- <li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
35
- </ul>
36
- </div>
37
- </div>
38
- <div id="header">
39
- <div class="wrapper clearfix">
40
- <h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
41
- <ul class="nav">
42
- <li><a class="nav-item" href="index.html">Home</a></li>
43
- <li class="guides-index guides-index-large">
44
- <a href="index.html" id="guidesMenu" class="guides-index-item nav-item">Guides Index</a>
45
- <div id="guides" class="clearfix" style="display: none;">
46
- <hr />
47
- <dl class="L">
48
- <dt>Start Here</dt>
49
- <dd><a href="getting_started.html">Getting Started with Rails</a></dd>
50
- <dt>Models</dt>
51
- <dd><a href="active_record_basics.html">Active Record Basics</a></dd>
52
- <dd><a href="active_record_migrations.html">Active Record Migrations</a></dd>
53
- <dd><a href="active_record_validations.html">Active Record Validations</a></dd>
54
- <dd><a href="active_record_callbacks.html">Active Record Callbacks</a></dd>
55
- <dd><a href="association_basics.html">Active Record Associations</a></dd>
56
- <dd><a href="active_record_querying.html">Active Record Query Interface</a></dd>
57
- <dt>Views</dt>
58
- <dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd>
59
- <dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
60
- <dt>Controllers</dt>
61
- <dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
62
- <dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
63
- </dl>
64
- <dl class="R">
65
- <dt>Digging Deeper</dt>
66
- <dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
67
- <dd><a href="i18n.html">Rails Internationalization API</a></dd>
68
- <dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
69
- <dd><a href="active_job_basics.html">Active Job Basics</a></dd>
70
- <dd><a href="security.html">Securing Rails Applications</a></dd>
71
- <dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
72
- <dd><a href="configuring.html">Configuring Rails Applications</a></dd>
73
- <dd><a href="command_line.html">Rails Command Line Tools and Rake Tasks</a></dd>
74
- <dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
75
- <dd><a href="working_with_javascript_in_rails.html">Working with JavaScript in Rails</a></dd>
76
- <dt>Extending Rails</dt>
77
- <dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
78
- <dd><a href="generators.html">Creating and Customizing Rails Generators</a></dd>
79
- <dt>Contributing to Ruby on Rails</dt>
80
- <dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
81
- <dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
82
- <dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
83
- <dt>Maintenance Policy</dt>
84
- <dd><a href="maintenance_policy.html">Maintenance Policy</a></dd>
85
- <dt>Release Notes</dt>
86
- <dd><a href="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</a></dd>
87
- <dd><a href="4_1_release_notes.html">Ruby on Rails 4.1 Release Notes</a></dd>
88
- <dd><a href="4_0_release_notes.html">Ruby on Rails 4.0 Release Notes</a></dd>
89
- <dd><a href="3_2_release_notes.html">Ruby on Rails 3.2 Release Notes</a></dd>
90
- <dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
91
- <dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
92
- <dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
93
- <dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
94
- </dl>
95
- </div>
96
- </li>
97
- <li><a class="nav-item" href="contributing_to_ruby_on_rails.html">Contribute</a></li>
98
- <li><a class="nav-item" href="credits.html">Credits</a></li>
99
- <li class="guides-index guides-index-small">
100
- <select class="guides-index-item nav-item">
101
- <option value="index.html">Guides Index</option>
102
- <optgroup label="Start Here">
103
- <option value="getting_started.html">Getting Started with Rails</option>
104
- </optgroup>
105
- <optgroup label="Models">
106
- <option value="active_record_basics.html">Active Record Basics</option>
107
- <option value="active_record_migrations.html">Active Record Migrations</option>
108
- <option value="active_record_validations.html">Active Record Validations</option>
109
- <option value="active_record_callbacks.html">Active Record Callbacks</option>
110
- <option value="association_basics.html">Active Record Associations</option>
111
- <option value="active_record_querying.html">Active Record Query Interface</option>
112
- </optgroup>
113
- <optgroup label="Views">
114
- <option value="layouts_and_rendering.html">Layouts and Rendering in Rails</option>
115
- <option value="form_helpers.html">Action View Form Helpers</option>
116
- </optgroup>
117
- <optgroup label="Controllers">
118
- <option value="action_controller_overview.html">Action Controller Overview</option>
119
- <option value="routing.html">Rails Routing from the Outside In</option>
120
- </optgroup>
121
- <optgroup label="Digging Deeper">
122
- <option value="active_support_core_extensions.html">Active Support Core Extensions</option>
123
- <option value="i18n.html">Rails Internationalization API</option>
124
- <option value="action_mailer_basics.html">Action Mailer Basics</option>
125
- <option value="active_job_basics.html">Active Job Basics</option>
126
- <option value="security.html">Securing Rails Applications</option>
127
- <option value="debugging_rails_applications.html">Debugging Rails Applications</option>
128
- <option value="configuring.html">Configuring Rails Applications</option>
129
- <option value="command_line.html">Rails Command Line Tools and Rake Tasks</option>
130
- <option value="asset_pipeline.html">Asset Pipeline</option>
131
- <option value="working_with_javascript_in_rails.html">Working with JavaScript in Rails</option>
132
- </optgroup>
133
- <optgroup label="Extending Rails">
134
- <option value="rails_on_rack.html">Rails on Rack</option>
135
- <option value="generators.html">Creating and Customizing Rails Generators</option>
136
- </optgroup>
137
- <optgroup label="Contributing to Ruby on Rails">
138
- <option value="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</option>
139
- <option value="api_documentation_guidelines.html">API Documentation Guidelines</option>
140
- <option value="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</option>
141
- </optgroup>
142
- <optgroup label="Maintenance Policy">
143
- <option value="maintenance_policy.html">Maintenance Policy</option>
144
- </optgroup>
145
- <optgroup label="Release Notes">
146
- <option value="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</option>
147
- <option value="4_1_release_notes.html">Ruby on Rails 4.1 Release Notes</option>
148
- <option value="4_0_release_notes.html">Ruby on Rails 4.0 Release Notes</option>
149
- <option value="3_2_release_notes.html">Ruby on Rails 3.2 Release Notes</option>
150
- <option value="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</option>
151
- <option value="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</option>
152
- <option value="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</option>
153
- <option value="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</option>
154
- </optgroup>
155
- </select>
156
- </li>
157
- </ul>
158
- </div>
159
- </div>
160
- <hr class="hide" />
161
-
162
- <div id="feature">
163
- <div class="wrapper">
164
- <h2>API Documentation Guidelines</h2><p>This guide documents the Ruby on Rails API documentation guidelines.</p><p>After reading this guide, you will know:</p>
165
- <ul>
166
- <li>How to write effective prose for documentation purposes.</li>
167
- <li>Style guidelines for documenting different kinds of Ruby code.</li>
168
- </ul>
169
-
170
-
171
- <div id="subCol">
172
- <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
173
- <ol class="chapters">
174
- <li><a href="#rdoc">RDoc</a></li>
175
- <li><a href="#wording">Wording</a></li>
176
- <li><a href="#english">English</a></li>
177
- <li><a href="#example-code">Example Code</a></li>
178
- <li><a href="#booleans">Booleans</a></li>
179
- <li><a href="#file-names">File Names</a></li>
180
- <li>
181
- <a href="#fonts">Fonts</a>
182
-
183
- <ul>
184
- <li><a href="#fixed-width-font">Fixed-width Font</a></li>
185
- <li><a href="#regular-font">Regular Font</a></li>
186
- </ul>
187
- </li>
188
- <li><a href="#description-lists">Description Lists</a></li>
189
- <li><a href="#dynamically-generated-methods">Dynamically Generated Methods</a></li>
190
- <li><a href="#method-visibility">Method Visibility</a></li>
191
- <li><a href="#regarding-the-rails-stack">Regarding the Rails Stack</a></li>
192
- </ol>
193
-
194
- </div>
195
-
196
- </div>
197
- </div>
198
-
199
- <div id="container">
200
- <div class="wrapper">
201
- <div id="mainCol">
202
- <h3 id="rdoc">1 RDoc</h3><p>The <a href="http://api.rubyonrails.org">Rails API documentation</a> is generated with
203
- <a href="http://docs.seattlerb.org/rdoc/">RDoc</a>.</p><div class="code_container">
204
- <pre class="brush: plain; gutter: false; toolbar: false">
205
- bundle exec rake rdoc
206
-
207
- </pre>
208
- </div>
209
- <p>Resulting HTML files can be found in the ./doc/rdoc directory.</p><p>Please consult the RDoc documentation for help with the
210
- <a href="http://docs.seattlerb.org/rdoc/RDoc/Markup.html">markup</a>,
211
- and also take into account these <a href="http://docs.seattlerb.org/rdoc/RDoc/Parser/Ruby.html">additional
212
- directives</a>.</p><h3 id="wording">2 Wording</h3><p>Write simple, declarative sentences. Brevity is a plus: get to the point.</p><p>Write in present tense: "Returns a hash that...", rather than "Returned a hash that..." or "Will return a hash that...".</p><p>Start comments in upper case. Follow regular punctuation rules:</p><div class="code_container">
213
- <pre class="brush: ruby; gutter: false; toolbar: false">
214
- # Declares an attribute reader backed by an internally-named
215
- # instance variable.
216
- def attr_internal_reader(*attrs)
217
- ...
218
- end
219
-
220
- </pre>
221
- </div>
222
- <p>Communicate to the reader the current way of doing things, both explicitly and implicitly. Use the idioms recommended in edge. Reorder sections to emphasize favored approaches if needed, etc. The documentation should be a model for best practices and canonical, modern Rails usage.</p><p>Documentation has to be concise but comprehensive. Explore and document edge cases. What happens if a module is anonymous? What if a collection is empty? What if an argument is nil?</p><p>The proper names of Rails components have a space in between the words, like "Active Support". <code>ActiveRecord</code> is a Ruby module, whereas Active Record is an ORM. All Rails documentation should consistently refer to Rails components by their proper name, and if in your next blog post or presentation you remember this tidbit and take it into account that'd be phenomenal.</p><p>Spell names correctly: Arel, Test::Unit, RSpec, HTML, MySQL, JavaScript, ERB. When in doubt, please have a look at some authoritative source like their official documentation.</p><p>Use the article "an" for "SQL", as in "an SQL statement". Also "an SQLite database".</p><p>Prefer wordings that avoid "you"s and "your"s. For example, instead of</p><div class="code_container">
223
- <pre class="brush: plain; gutter: false; toolbar: false">
224
- If you need to use `return` statements in your callbacks, it is recommended that you explicitly define them as methods.
225
-
226
- </pre>
227
- </div>
228
- <p>use this style:</p><div class="code_container">
229
- <pre class="brush: plain; gutter: false; toolbar: false">
230
- If `return` is needed it is recommended to explicitly define a method.
231
-
232
- </pre>
233
- </div>
234
- <p>That said, when using pronouns in reference to a hypothetical person, such as "a
235
- user with a session cookie", gender neutral pronouns (they/their/them) should be
236
- used. Instead of:</p>
237
- <ul>
238
- <li>he or she... use they.</li>
239
- <li>him or her... use them.</li>
240
- <li>his or her... use their.</li>
241
- <li>his or hers... use theirs.</li>
242
- <li>himself or herself... use themselves.</li>
243
- </ul>
244
- <h3 id="english">3 English</h3><p>Please use American English (<em>color</em>, <em>center</em>, <em>modularize</em>, etc). See <a href="http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences">a list of American and British English spelling differences here</a>.</p><h3 id="example-code">4 Example Code</h3><p>Choose meaningful examples that depict and cover the basics as well as interesting points or gotchas.</p><p>Use two spaces to indent chunks of code--that is, for markup purposes, two spaces with respect to the left margin. The examples themselves should use <a href="contributing_to_ruby_on_rails.html#follow-the-coding-conventions">Rails coding conventions</a>.</p><p>Short docs do not need an explicit "Examples" label to introduce snippets; they just follow paragraphs:</p><div class="code_container">
245
- <pre class="brush: ruby; gutter: false; toolbar: false">
246
- # Converts a collection of elements into a formatted string by
247
- # calling +to_s+ on all elements and joining them.
248
- #
249
- # Blog.all.to_formatted_s # =&gt; "First PostSecond PostThird Post"
250
-
251
- </pre>
252
- </div>
253
- <p>On the other hand, big chunks of structured documentation may have a separate "Examples" section:</p><div class="code_container">
254
- <pre class="brush: ruby; gutter: false; toolbar: false">
255
- # ==== Examples
256
- #
257
- # Person.exists?(5)
258
- # Person.exists?('5')
259
- # Person.exists?(name: "David")
260
- # Person.exists?(['name LIKE ?', "%#{query}%"])
261
-
262
- </pre>
263
- </div>
264
- <p>The results of expressions follow them and are introduced by "# =&gt; ", vertically aligned:</p><div class="code_container">
265
- <pre class="brush: ruby; gutter: false; toolbar: false">
266
- # For checking if a fixnum is even or odd.
267
- #
268
- # 1.even? # =&gt; false
269
- # 1.odd? # =&gt; true
270
- # 2.even? # =&gt; true
271
- # 2.odd? # =&gt; false
272
-
273
- </pre>
274
- </div>
275
- <p>If a line is too long, the comment may be placed on the next line:</p><div class="code_container">
276
- <pre class="brush: ruby; gutter: false; toolbar: false">
277
- # label(:article, :title)
278
- # # =&gt; &lt;label for="article_title"&gt;Title&lt;/label&gt;
279
- #
280
- # label(:article, :title, "A short title")
281
- # # =&gt; &lt;label for="article_title"&gt;A short title&lt;/label&gt;
282
- #
283
- # label(:article, :title, "A short title", class: "title_label")
284
- # # =&gt; &lt;label for="article_title" class="title_label"&gt;A short title&lt;/label&gt;
285
-
286
- </pre>
287
- </div>
288
- <p>Avoid using any printing methods like <code>puts</code> or <code>p</code> for that purpose.</p><p>On the other hand, regular comments do not use an arrow:</p><div class="code_container">
289
- <pre class="brush: ruby; gutter: false; toolbar: false">
290
- # polymorphic_url(record) # same as comment_url(record)
291
-
292
- </pre>
293
- </div>
294
- <h3 id="booleans">5 Booleans</h3><p>In predicates and flags prefer documenting boolean semantics over exact values.</p><p>When "true" or "false" are used as defined in Ruby use regular font. The
295
- singletons <code>true</code> and <code>false</code> need fixed-width font. Please avoid terms like
296
- "truthy", Ruby defines what is true and false in the language, and thus those
297
- words have a technical meaning and need no substitutes.</p><p>As a rule of thumb, do not document singletons unless absolutely necessary. That
298
- prevents artificial constructs like <code>!!</code> or ternaries, allows refactors, and the
299
- code does not need to rely on the exact values returned by methods being called
300
- in the implementation.</p><p>For example:</p><div class="code_container">
301
- <pre class="brush: plain; gutter: false; toolbar: false">
302
- `config.action_mailer.perform_deliveries` specifies whether mail will actually be delivered and is true by default
303
-
304
- </pre>
305
- </div>
306
- <p>the user does not need to know which is the actual default value of the flag,
307
- and so we only document its boolean semantics.</p><p>An example with a predicate:</p><div class="code_container">
308
- <pre class="brush: ruby; gutter: false; toolbar: false">
309
- # Returns true if the collection is empty.
310
- #
311
- # If the collection has been loaded
312
- # it is equivalent to &lt;tt&gt;collection.size.zero?&lt;/tt&gt;. If the
313
- # collection has not been loaded, it is equivalent to
314
- # &lt;tt&gt;collection.exists?&lt;/tt&gt;. If the collection has not already been
315
- # loaded and you are going to fetch the records anyway it is better to
316
- # check &lt;tt&gt;collection.length.zero?&lt;/tt&gt;.
317
- def empty?
318
- if loaded?
319
- size.zero?
320
- else
321
- @target.blank? &amp;&amp; !scope.exists?
322
- end
323
- end
324
-
325
- </pre>
326
- </div>
327
- <p>The API is careful not to commit to any particular value, the method has
328
- predicate semantics, that's enough.</p><h3 id="file-names">6 File Names</h3><p>As a rule of thumb, use filenames relative to the application root:</p><div class="code_container">
329
- <pre class="brush: plain; gutter: false; toolbar: false">
330
- config/routes.rb # YES
331
- routes.rb # NO
332
- RAILS_ROOT/config/routes.rb # NO
333
-
334
- </pre>
335
- </div>
336
- <h3 id="fonts">7 Fonts</h3><h4 id="fixed-width-font">7.1 Fixed-width Font</h4><p>Use fixed-width fonts for:</p>
337
- <ul>
338
- <li>Constants, in particular class and module names.</li>
339
- <li>Method names.</li>
340
- <li>Literals like <code>nil</code>, <code>false</code>, <code>true</code>, <code>self</code>.</li>
341
- <li>Symbols.</li>
342
- <li>Method parameters.</li>
343
- <li>File names.</li>
344
- </ul>
345
- <div class="code_container">
346
- <pre class="brush: ruby; gutter: false; toolbar: false">
347
- class Array
348
- # Calls +to_param+ on all its elements and joins the result with
349
- # slashes. This is used by +url_for+ in Action Pack.
350
- def to_param
351
- collect { |e| e.to_param }.join '/'
352
- end
353
- end
354
-
355
- </pre>
356
- </div>
357
- <div class="warning"><p>Using <code>+...+</code> for fixed-width font only works with simple content like
358
- ordinary method names, symbols, paths (with forward slashes), etc. Please use
359
- <code>&lt;tt&gt;...&lt;/tt&gt;</code> for everything else, notably class or module names with a
360
- namespace as in <code>&lt;tt&gt;ActiveRecord::Base&lt;/tt&gt;</code>.</p></div><p>You can quickly test the RDoc output with the following command:</p><div class="code_container">
361
- <pre class="brush: plain; gutter: false; toolbar: false">
362
- $ echo "+:to_param+" | rdoc --pipe
363
- #=&gt; &lt;p&gt;&lt;code&gt;:to_param&lt;/code&gt;&lt;/p&gt;
364
-
365
- </pre>
366
- </div>
367
- <h4 id="regular-font">7.2 Regular Font</h4><p>When "true" and "false" are English words rather than Ruby keywords use a regular font:</p><div class="code_container">
368
- <pre class="brush: ruby; gutter: false; toolbar: false">
369
- # Runs all the validations within the specified context.
370
- # Returns true if no errors are found, false otherwise.
371
- #
372
- # If the argument is false (default is +nil+), the context is
373
- # set to &lt;tt&gt;:create&lt;/tt&gt; if &lt;tt&gt;new_record?&lt;/tt&gt; is true,
374
- # and to &lt;tt&gt;:update&lt;/tt&gt; if it is not.
375
- #
376
- # Validations with no &lt;tt&gt;:on&lt;/tt&gt; option will run no
377
- # matter the context. Validations with # some &lt;tt&gt;:on&lt;/tt&gt;
378
- # option will only run in the specified context.
379
- def valid?(context = nil)
380
- ...
381
- end
382
-
383
- </pre>
384
- </div>
385
- <h3 id="description-lists">8 Description Lists</h3><p>In lists of options, parameters, etc. use a hyphen between the item and its description (reads better than a colon because normally options are symbols):</p><div class="code_container">
386
- <pre class="brush: ruby; gutter: false; toolbar: false">
387
- # * &lt;tt&gt;:allow_nil&lt;/tt&gt; - Skip validation if attribute is +nil+.
388
-
389
- </pre>
390
- </div>
391
- <p>The description starts in upper case and ends with a full stop-it's standard English.</p><h3 id="dynamically-generated-methods">9 Dynamically Generated Methods</h3><p>Methods created with <code>(module|class)_eval(STRING)</code> have a comment by their side with an instance of the generated code. That comment is 2 spaces away from the template:</p><div class="code_container">
392
- <pre class="brush: ruby; gutter: false; toolbar: false">
393
- for severity in Severity.constants
394
- class_eval &lt;&lt;-EOT, __FILE__, __LINE__
395
- def #{severity.downcase}(message = nil, progname = nil, &amp;block) # def debug(message = nil, progname = nil, &amp;block)
396
- add(#{severity}, message, progname, &amp;block) # add(DEBUG, message, progname, &amp;block)
397
- end # end
398
- #
399
- def #{severity.downcase}? # def debug?
400
- #{severity} &gt;= @level # DEBUG &gt;= @level
401
- end # end
402
- EOT
403
- end
404
-
405
- </pre>
406
- </div>
407
- <p>If the resulting lines are too wide, say 200 columns or more, put the comment above the call:</p><div class="code_container">
408
- <pre class="brush: ruby; gutter: false; toolbar: false">
409
- # def self.find_by_login_and_activated(*args)
410
- # options = args.extract_options!
411
- # ...
412
- # end
413
- self.class_eval %{
414
- def self.#{method_id}(*args)
415
- options = args.extract_options!
416
- ...
417
- end
418
- }
419
-
420
- </pre>
421
- </div>
422
- <h3 id="method-visibility">10 Method Visibility</h3><p>When writing documentation for Rails, it's important to understand the difference between public user-facing API vs internal API.</p><p>Rails, like most libraries, uses the private keyword from Ruby for defining internal API. However, public API follows a slightly different convention. Instead of assuming all public methods are designed for user consumption, Rails uses the <code>:nodoc:</code> directive to annotate these kinds of methods as internal API.</p><p>This means that there are methods in Rails with <code>public</code> visibility that aren't meant for user consumption.</p><p>An example of this is <code>ActiveRecord::Core::ClassMethods#arel_table</code>:</p><div class="code_container">
423
- <pre class="brush: ruby; gutter: false; toolbar: false">
424
- module ActiveRecord::Core::ClassMethods
425
- def arel_table #:nodoc:
426
- # do some magic..
427
- end
428
- end
429
-
430
- </pre>
431
- </div>
432
- <p>If you thought, "this method looks like a public class method for <code>ActiveRecord::Core</code>", you were right. But actually the Rails team doesn't want users to rely on this method. So they mark it as <code>:nodoc:</code> and it's removed from public documentation. The reasoning behind this is to allow the team to change these methods according to their internal needs across releases as they see fit. The name of this method could change, or the return value, or this entire class may disappear; there's no guarantee and so you shouldn't depend on this API in your plugins or applications. Otherwise, you risk your app or gem breaking when you upgrade to a newer release of Rails.</p><p>As a contributor, it's important to think about whether this API is meant for end-user consumption. The Rails team is committed to not making any breaking changes to public API across releases without going through a full deprecation cycle. It's recommended that you <code>:nodoc:</code> any of your internal methods/classes unless they're already private (meaning visibility), in which case it's internal by default. Once the API stabilizes the visibility can change, but changing public API is much harder due to backwards compatibility.</p><p>A class or module is marked with <code>:nodoc:</code> to indicate that all methods are internal API and should never be used directly.</p><p>If you come across an existing <code>:nodoc:</code> you should tread lightly. Consider asking someone from the core team or author of the code before removing it. This should almost always happen through a pull request instead of the docrails project.</p><p>A <code>:nodoc:</code> should never be added simply because a method or class is missing documentation. There may be an instance where an internal public method wasn't given a <code>:nodoc:</code> by mistake, for example when switching a method from private to public visibility. When this happens it should be discussed over a PR on a case-by-case basis and never committed directly to docrails.</p><p>To summarize, the Rails team uses <code>:nodoc:</code> to mark publicly visible methods and classes for internal use; changes to the visibility of API should be considered carefully and discussed over a pull request first.</p><h3 id="regarding-the-rails-stack">11 Regarding the Rails Stack</h3><p>When documenting parts of Rails API, it's important to remember all of the
433
- pieces that go into the Rails stack.</p><p>This means that behavior may change depending on the scope or context of the
434
- method or class you're trying to document.</p><p>In various places there is different behavior when you take the entire stack
435
- into account, one such example is
436
- <code>ActionView::Helpers::AssetTagHelper#image_tag</code>:</p><div class="code_container">
437
- <pre class="brush: ruby; gutter: false; toolbar: false">
438
- # image_tag("icon.png")
439
- # # =&gt; &lt;img alt="Icon" src="/assets/icon.png" /&gt;
440
-
441
- </pre>
442
- </div>
443
- <p>Although the default behavior for <code>#image_tag</code> is to always return
444
- <code>/images/icon.png</code>, we take into account the full Rails stack (including the
445
- Asset Pipeline) we may see the result seen above.</p><p>We're only concerned with the behavior experienced when using the full default
446
- Rails stack.</p><p>In this case, we want to document the behavior of the <em>framework</em>, and not just
447
- this specific method.</p><p>If you have a question on how the Rails team handles certain API, don't hesitate to open a ticket or send a patch to the <a href="https://github.com/rails/rails/issues">issue tracker</a>.</p>
448
-
449
- <h3>Feedback</h3>
450
- <p>
451
- You're encouraged to help improve the quality of this guide.
452
- </p>
453
- <p>
454
- Please contribute if you see any typos or factual errors.
455
- To get started, you can read our <a href="http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation">documentation contributions</a> section.
456
- </p>
457
- <p>
458
- You may also find incomplete content, or stuff that is not up to date.
459
- Please do add any missing documentation for master. Make sure to check
460
- <a href="http://edgeguides.rubyonrails.org">Edge Guides</a> first to verify
461
- if the issues are already fixed or not on the master branch.
462
- Check the <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
463
- for style and conventions.
464
- </p>
465
- <p>
466
- If for whatever reason you spot something to fix but cannot patch it yourself, please
467
- <a href="https://github.com/rails/rails/issues">open an issue</a>.
468
- </p>
469
- <p>And last but not least, any kind of discussion regarding Ruby on Rails
470
- documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
471
- </p>
472
- </div>
473
- </div>
474
- </div>
475
-
476
- <hr class="hide" />
477
- <div id="footer">
478
- <div class="wrapper">
479
- <p>This work is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</a> License</p>
480
- <p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
481
-
482
- </div>
483
- </div>
484
-
485
- <script type="text/javascript" src="javascripts/jquery.min.js"></script>
486
- <script type="text/javascript" src="javascripts/responsive-tables.js"></script>
487
- <script type="text/javascript" src="javascripts/guides.js"></script>
488
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
489
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
490
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
491
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
492
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
493
- <script type="text/javascript">
494
- SyntaxHighlighter.all();
495
- $(guidesIndex.bind);
496
- </script>
497
- </body>
498
- </html>