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,870 +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>Ruby on Rails 2.3 Release Notes — 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>Ruby on Rails 2.3 Release Notes</h2><p>Rails 2.3 delivers a variety of new and improved features, including pervasive Rack integration, refreshed support for Rails Engines, nested transactions for Active Record, dynamic and default scopes, unified rendering, more efficient routing, application templates, and quiet backtraces. This list covers the major upgrades, but doesn&#39;t include every little bug fix and change. If you want to see everything, check out the <a href="http://github.com/rails/rails/commits/master">list of commits</a> in the main Rails repository on GitHub or review the <code>CHANGELOG</code> files for the individual Rails components.</p>
165
-
166
- <div id="subCol">
167
- <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
168
- <ol class="chapters">
169
- <li>
170
- <a href="#application-architecture">Application Architecture</a>
171
-
172
- <ul>
173
- <li><a href="#rack-integration">Rack Integration</a></li>
174
- <li><a href="#renewed-support-for-rails-engines">Renewed Support for Rails Engines</a></li>
175
- </ul>
176
- </li>
177
- <li><a href="#documentation">Documentation</a></li>
178
- <li><a href="#ruby-1.9.1-support">Ruby 1.9.1 Support</a></li>
179
- <li>
180
- <a href="#active-record">Active Record</a>
181
-
182
- <ul>
183
- <li><a href="#nested-attributes">Nested Attributes</a></li>
184
- <li><a href="#nested-transactions">Nested Transactions</a></li>
185
- <li><a href="#dynamic-scopes">Dynamic Scopes</a></li>
186
- <li><a href="#default-scopes">Default Scopes</a></li>
187
- <li><a href="#batch-processing">Batch Processing</a></li>
188
- <li><a href="#multiple-conditions-for-callbacks">Multiple Conditions for Callbacks</a></li>
189
- <li><a href="#find-with-having">Find with having</a></li>
190
- <li><a href="#reconnecting-mysql-connections">Reconnecting MySQL Connections</a></li>
191
- <li><a href="#other-active-record-changes">Other Active Record Changes</a></li>
192
- </ul>
193
- </li>
194
- <li>
195
- <a href="#action-controller">Action Controller</a>
196
-
197
- <ul>
198
- <li><a href="#unified-rendering">Unified Rendering</a></li>
199
- <li><a href="#application-controller-renamed">Application Controller Renamed</a></li>
200
- <li><a href="#http-digest-authentication-support">HTTP Digest Authentication Support</a></li>
201
- <li><a href="#more-efficient-routing">More Efficient Routing</a></li>
202
- <li><a href="#rack-based-lazy-loaded-sessions">Rack-based Lazy-loaded Sessions</a></li>
203
- <li><a href="#mime-type-handling-changes">MIME Type Handling Changes</a></li>
204
- <li><a href="#optimization-of-respond_to">Optimization of <code>respond_to</code></a></li>
205
- <li><a href="#improved-caching-performance">Improved Caching Performance</a></li>
206
- <li><a href="#localized-views">Localized Views</a></li>
207
- <li><a href="#partial-scoping-for-translations">Partial Scoping for Translations</a></li>
208
- <li><a href="#other-action-controller-changes">Other Action Controller Changes</a></li>
209
- </ul>
210
- </li>
211
- <li>
212
- <a href="#action-view">Action View</a>
213
-
214
- <ul>
215
- <li><a href="#nested-object-forms">Nested Object Forms</a></li>
216
- <li><a href="#smart-rendering-of-partials">Smart Rendering of Partials</a></li>
217
- <li><a href="#prompts-for-date-select-helpers">Prompts for Date Select Helpers</a></li>
218
- <li><a href="#assettag-timestamp-caching">AssetTag Timestamp Caching</a></li>
219
- <li><a href="#asset-hosts-as-objects">Asset Hosts as Objects</a></li>
220
- <li><a href="#grouped_options_for_select-helper-method">grouped_options_for_select Helper Method</a></li>
221
- <li><a href="#disabled-option-tags-for-form-select-helpers">Disabled Option Tags for Form Select Helpers</a></li>
222
- <li><a href="#a-note-about-template-loading">A Note About Template Loading</a></li>
223
- <li><a href="#other-action-view-changes">Other Action View Changes</a></li>
224
- </ul>
225
- </li>
226
- <li>
227
- <a href="#active-support">Active Support</a>
228
-
229
- <ul>
230
- <li><a href="#object#try">Object#try</a></li>
231
- <li><a href="#object#tap-backport">Object#tap Backport</a></li>
232
- <li><a href="#swappable-parsers-for-xmlmini">Swappable Parsers for XMLmini</a></li>
233
- <li><a href="#fractional-seconds-for-timewithzone">Fractional seconds for TimeWithZone</a></li>
234
- <li><a href="#json-key-quoting">JSON Key Quoting</a></li>
235
- <li><a href="#other-active-support-changes">Other Active Support Changes</a></li>
236
- </ul>
237
- </li>
238
- <li>
239
- <a href="#railties">Railties</a>
240
-
241
- <ul>
242
- <li><a href="#rails-metal">Rails Metal</a></li>
243
- <li><a href="#application-templates">Application Templates</a></li>
244
- <li><a href="#quieter-backtraces">Quieter Backtraces</a></li>
245
- <li><a href="#faster-boot-time-in-development-mode-with-lazy-loading/autoload">Faster Boot Time in Development Mode with Lazy Loading/Autoload</a></li>
246
- <li><a href="#rake-gem-task-rewrite">rake gem Task Rewrite</a></li>
247
- <li><a href="#other-railties-changes">Other Railties Changes</a></li>
248
- </ul>
249
- </li>
250
- <li><a href="#deprecated">Deprecated</a></li>
251
- <li><a href="#credits">Credits</a></li>
252
- </ol>
253
-
254
- </div>
255
-
256
- </div>
257
- </div>
258
-
259
- <div id="container">
260
- <div class="wrapper">
261
- <div id="mainCol">
262
- <h3 id="application-architecture">1 Application Architecture</h3><p>There are two major changes in the architecture of Rails applications: complete integration of the <a href="http://rack.github.io/">Rack</a> modular web server interface, and renewed support for Rails Engines.</p><h4 id="rack-integration">1.1 Rack Integration</h4><p>Rails has now broken with its CGI past, and uses Rack everywhere. This required and resulted in a tremendous number of internal changes (but if you use CGI, don't worry; Rails now supports CGI through a proxy interface.) Still, this is a major change to Rails internals. After upgrading to 2.3, you should test on your local environment and your production environment. Some things to test:</p>
263
- <ul>
264
- <li>Sessions</li>
265
- <li>Cookies</li>
266
- <li>File uploads</li>
267
- <li>JSON/XML APIs</li>
268
- </ul>
269
- <p>Here's a summary of the rack-related changes:</p>
270
- <ul>
271
- <li>
272
- <code>script/server</code> has been switched to use Rack, which means it supports any Rack compatible server. <code>script/server</code> will also pick up a rackup configuration file if one exists. By default, it will look for a <code>config.ru</code> file, but you can override this with the <code>-c</code> switch.</li>
273
- <li>The FCGI handler goes through Rack.</li>
274
- <li>
275
- <code>ActionController::Dispatcher</code> maintains its own default middleware stack. Middlewares can be injected in, reordered, and removed. The stack is compiled into a chain on boot. You can configure the middleware stack in <code>environment.rb</code>.</li>
276
- <li>The <code>rake middleware</code> task has been added to inspect the middleware stack. This is useful for debugging the order of the middleware stack.</li>
277
- <li>The integration test runner has been modified to execute the entire middleware and application stack. This makes integration tests perfect for testing Rack middleware.</li>
278
- <li>
279
- <code>ActionController::CGIHandler</code> is a backwards compatible CGI wrapper around Rack. The <code>CGIHandler</code> is meant to take an old CGI object and convert its environment information into a Rack compatible form.</li>
280
- <li>
281
- <code>CgiRequest</code> and <code>CgiResponse</code> have been removed.</li>
282
- <li>Session stores are now lazy loaded. If you never access the session object during a request, it will never attempt to load the session data (parse the cookie, load the data from memcache, or lookup an Active Record object).</li>
283
- <li>You no longer need to use <code>CGI::Cookie.new</code> in your tests for setting a cookie value. Assigning a <code>String</code> value to request.cookies["foo"] now sets the cookie as expected.</li>
284
- <li>
285
- <code>CGI::Session::CookieStore</code> has been replaced by <code>ActionController::Session::CookieStore</code>.</li>
286
- <li>
287
- <code>CGI::Session::MemCacheStore</code> has been replaced by <code>ActionController::Session::MemCacheStore</code>.</li>
288
- <li>
289
- <code>CGI::Session::ActiveRecordStore</code> has been replaced by <code>ActiveRecord::SessionStore</code>.</li>
290
- <li>You can still change your session store with <code>ActionController::Base.session_store = :active_record_store</code>.</li>
291
- <li>Default sessions options are still set with <code>ActionController::Base.session = { :key =&gt; "..." }</code>. However, the <code>:session_domain</code> option has been renamed to <code>:domain</code>.</li>
292
- <li>The mutex that normally wraps your entire request has been moved into middleware, <code>ActionController::Lock</code>.</li>
293
- <li>
294
- <code>ActionController::AbstractRequest</code> and <code>ActionController::Request</code> have been unified. The new <code>ActionController::Request</code> inherits from <code>Rack::Request</code>. This affects access to <code>response.headers['type']</code> in test requests. Use <code>response.content_type</code> instead.</li>
295
- <li>
296
- <code>ActiveRecord::QueryCache</code> middleware is automatically inserted onto the middleware stack if <code>ActiveRecord</code> has been loaded. This middleware sets up and flushes the per-request Active Record query cache.</li>
297
- <li>The Rails router and controller classes follow the Rack spec. You can call a controller directly with <code>SomeController.call(env)</code>. The router stores the routing parameters in <code>rack.routing_args</code>.</li>
298
- <li>
299
- <code>ActionController::Request</code> inherits from <code>Rack::Request</code>.</li>
300
- <li>Instead of <code>config.action_controller.session = { :session_key =&gt; 'foo', ...</code> use <code>config.action_controller.session = { :key =&gt; 'foo', ...</code>.</li>
301
- <li>Using the <code>ParamsParser</code> middleware preprocesses any XML, JSON, or YAML requests so they can be read normally with any <code>Rack::Request</code> object after it.</li>
302
- </ul>
303
- <h4 id="renewed-support-for-rails-engines">1.2 Renewed Support for Rails Engines</h4><p>After some versions without an upgrade, Rails 2.3 offers some new features for Rails Engines (Rails applications that can be embedded within other applications). First, routing files in engines are automatically loaded and reloaded now, just like your <code>routes.rb</code> file (this also applies to routing files in other plugins). Second, if your plugin has an app folder, then app/[models|controllers|helpers] will automatically be added to the Rails load path. Engines also support adding view paths now, and Action Mailer as well as Action View will use views from engines and other plugins.</p><h3 id="documentation">2 Documentation</h3><p>The <a href="http://guides.rubyonrails.org/">Ruby on Rails guides</a> project has published several additional guides for Rails 2.3. In addition, a <a href="http://edgeguides.rubyonrails.org/">separate site</a> maintains updated copies of the Guides for Edge Rails. Other documentation efforts include a relaunch of the <a href="http://newwiki.rubyonrails.org/">Rails wiki</a> and early planning for a Rails Book.</p>
304
- <ul>
305
- <li>More Information: <a href="http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.">Rails Documentation Projects</a>
306
- </li>
307
- </ul>
308
- <h3 id="ruby-1.9.1-support">3 Ruby 1.9.1 Support</h3><p>Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.</p><h3 id="active-record">4 Active Record</h3><p>Active Record gets quite a number of new features and bug fixes in Rails 2.3. The highlights include nested attributes, nested transactions, dynamic and default scopes, and batch processing.</p><h4 id="nested-attributes">4.1 Nested Attributes</h4><p>Active Record can now update the attributes on nested models directly, provided you tell it to do so:</p><div class="code_container">
309
- <pre class="brush: ruby; gutter: false; toolbar: false">
310
- class Book &lt; ActiveRecord::Base
311
- has_one :author
312
- has_many :pages
313
-
314
- accepts_nested_attributes_for :author, :pages
315
- end
316
-
317
- </pre>
318
- </div>
319
- <p>Turning on nested attributes enables a number of things: automatic (and atomic) saving of a record together with its associated children, child-aware validations, and support for nested forms (discussed later).</p><p>You can also specify requirements for any new records that are added via nested attributes using the <code>:reject_if</code> option:</p><div class="code_container">
320
- <pre class="brush: ruby; gutter: false; toolbar: false">
321
- accepts_nested_attributes_for :author,
322
- :reject_if =&gt; proc { |attributes| attributes['name'].blank? }
323
-
324
- </pre>
325
- </div>
326
-
327
- <ul>
328
- <li>Lead Contributor: <a href="http://superalloy.nl/">Eloy Duran</a>
329
- </li>
330
- <li>More Information: <a href="http://weblog.rubyonrails.org/2009/1/26/nested-model-forms">Nested Model Forms</a>
331
- </li>
332
- </ul>
333
- <h4 id="nested-transactions">4.2 Nested Transactions</h4><p>Active Record now supports nested transactions, a much-requested feature. Now you can write code like this:</p><div class="code_container">
334
- <pre class="brush: ruby; gutter: false; toolbar: false">
335
- User.transaction do
336
- User.create(:username =&gt; 'Admin')
337
- User.transaction(:requires_new =&gt; true) do
338
- User.create(:username =&gt; 'Regular')
339
- raise ActiveRecord::Rollback
340
- end
341
- end
342
-
343
- User.find(:all) # =&gt; Returns only Admin
344
-
345
- </pre>
346
- </div>
347
- <p>Nested transactions let you roll back an inner transaction without affecting the state of the outer transaction. If you want a transaction to be nested, you must explicitly add the <code>:requires_new</code> option; otherwise, a nested transaction simply becomes part of the parent transaction (as it does currently on Rails 2.2). Under the covers, nested transactions are <a href="http://rails.lighthouseapp.com/projects/8994/tickets/383,">using savepoints</a> so they're supported even on databases that don't have true nested transactions. There is also a bit of magic going on to make these transactions play well with transactional fixtures during testing.</p>
348
- <ul>
349
- <li>Lead Contributors: <a href="http://www.workingwithrails.com/person/4985-jonathan-viney">Jonathan Viney</a> and <a href="http://izumi.plan99.net/blog/">Hongli Lai</a>
350
- </li>
351
- </ul>
352
- <h4 id="dynamic-scopes">4.3 Dynamic Scopes</h4><p>You know about dynamic finders in Rails (which allow you to concoct methods like <code>find_by_color_and_flavor</code> on the fly) and named scopes (which allow you to encapsulate reusable query conditions into friendly names like <code>currently_active</code>). Well, now you can have dynamic scope methods. The idea is to put together syntax that allows filtering on the fly <em>and</em> method chaining. For example:</p><div class="code_container">
353
- <pre class="brush: ruby; gutter: false; toolbar: false">
354
- Order.scoped_by_customer_id(12)
355
- Order.scoped_by_customer_id(12).find(:all,
356
- :conditions =&gt; "status = 'open'")
357
- Order.scoped_by_customer_id(12).scoped_by_status("open")
358
-
359
- </pre>
360
- </div>
361
- <p>There's nothing to define to use dynamic scopes: they just work.</p>
362
- <ul>
363
- <li>Lead Contributor: <a href="http://evilmartians.com/">Yaroslav Markin</a>
364
- </li>
365
- <li>More Information: <a href="http://ryandaigle.com/articles/2008/12/29/what-s-new-in-edge-rails-dynamic-scope-methods.">What's New in Edge Rails: Dynamic Scope Methods</a>
366
- </li>
367
- </ul>
368
- <h4 id="default-scopes">4.4 Default Scopes</h4><p>Rails 2.3 will introduce the notion of <em>default scopes</em> similar to named scopes, but applying to all named scopes or find methods within the model. For example, you can write <code>default_scope :order =&gt; 'name ASC'</code> and any time you retrieve records from that model they'll come out sorted by name (unless you override the option, of course).</p>
369
- <ul>
370
- <li>Lead Contributor: Paweł Kondzior</li>
371
- <li>More Information: <a href="http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping">What's New in Edge Rails: Default Scoping</a>
372
- </li>
373
- </ul>
374
- <h4 id="batch-processing">4.5 Batch Processing</h4><p>You can now process large numbers of records from an Active Record model with less pressure on memory by using <code>find_in_batches</code>:</p><div class="code_container">
375
- <pre class="brush: ruby; gutter: false; toolbar: false">
376
- Customer.find_in_batches(:conditions =&gt; {:active =&gt; true}) do |customer_group|
377
- customer_group.each { |customer| customer.update_account_balance! }
378
- end
379
-
380
- </pre>
381
- </div>
382
- <p>You can pass most of the <code>find</code> options into <code>find_in_batches</code>. However, you cannot specify the order that records will be returned in (they will always be returned in ascending order of primary key, which must be an integer), or use the <code>:limit</code> option. Instead, use the <code>:batch_size</code> option, which defaults to 1000, to set the number of records that will be returned in each batch.</p><p>The new <code>find_each</code> method provides a wrapper around <code>find_in_batches</code> that returns individual records, with the find itself being done in batches (of 1000 by default):</p><div class="code_container">
383
- <pre class="brush: ruby; gutter: false; toolbar: false">
384
- Customer.find_each do |customer|
385
- customer.update_account_balance!
386
- end
387
-
388
- </pre>
389
- </div>
390
- <p>Note that you should only use this method for batch processing: for small numbers of records (less than 1000), you should just use the regular find methods with your own loop.</p>
391
- <ul>
392
- <li>More Information (at that point the convenience method was called just <code>each</code>):
393
-
394
- <ul>
395
- <li><a href="http://afreshcup.com/2009/02/23/rails-23-batch-finding/">Rails 2.3: Batch Finding</a></li>
396
- <li><a href="http://ryandaigle.com/articles/2009/2/23/what-s-new-in-edge-rails-batched-find">What's New in Edge Rails: Batched Find</a></li>
397
- </ul>
398
- </li>
399
- </ul>
400
- <h4 id="multiple-conditions-for-callbacks">4.6 Multiple Conditions for Callbacks</h4><p>When using Active Record callbacks, you can now combine <code>:if</code> and <code>:unless</code> options on the same callback, and supply multiple conditions as an array:</p><div class="code_container">
401
- <pre class="brush: ruby; gutter: false; toolbar: false">
402
- before_save :update_credit_rating, :if =&gt; :active,
403
- :unless =&gt; [:admin, :cash_only]
404
-
405
- </pre>
406
- </div>
407
-
408
- <ul>
409
- <li>Lead Contributor: L. Caviola</li>
410
- </ul>
411
- <h4 id="find-with-having">4.7 Find with having</h4><p>Rails now has a <code>:having</code> option on find (as well as on <code>has_many</code> and <code>has_and_belongs_to_many</code> associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:</p><div class="code_container">
412
- <pre class="brush: ruby; gutter: false; toolbar: false">
413
- developers = Developer.find(:all, :group =&gt; "salary",
414
- :having =&gt; "sum(salary) &gt; 10000", :select =&gt; "salary")
415
-
416
- </pre>
417
- </div>
418
-
419
- <ul>
420
- <li>Lead Contributor: <a href="http://github.com/miloops">Emilio Tagua</a>
421
- </li>
422
- </ul>
423
- <h4 id="reconnecting-mysql-connections">4.8 Reconnecting MySQL Connections</h4><p>MySQL supports a reconnect flag in its connections - if set to true, then the client will try reconnecting to the server before giving up in case of a lost connection. You can now set <code>reconnect = true</code> for your MySQL connections in <code>database.yml</code> to get this behavior from a Rails application. The default is <code>false</code>, so the behavior of existing applications doesn't change.</p>
424
- <ul>
425
- <li>Lead Contributor: <a href="http://twitter.com/dubek">Dov Murik</a>
426
- </li>
427
- <li>More information:
428
-
429
- <ul>
430
- <li><a href="http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html">Controlling Automatic Reconnection Behavior</a></li>
431
- <li><a href="http://groups.google.com/group/rubyonrails-core/browse_thread/thread/49d2a7e9c96cb9f4">MySQL auto-reconnect revisited</a></li>
432
- </ul>
433
- </li>
434
- </ul>
435
- <h4 id="other-active-record-changes">4.9 Other Active Record Changes</h4>
436
- <ul>
437
- <li>An extra <code>AS</code> was removed from the generated SQL for <code>has_and_belongs_to_many</code> preloading, making it work better for some databases.</li>
438
- <li>
439
- <code>ActiveRecord::Base#new_record?</code> now returns <code>false</code> rather than <code>nil</code> when confronted with an existing record.</li>
440
- <li>A bug in quoting table names in some <code>has_many :through</code> associations was fixed.</li>
441
- <li>You can now specify a particular timestamp for <code>updated_at</code> timestamps: <code>cust = Customer.create(:name =&gt; "ABC Industries", :updated_at =&gt; 1.day.ago)</code>
442
- </li>
443
- <li>Better error messages on failed <code>find_by_attribute!</code> calls.</li>
444
- <li>Active Record's <code>to_xml</code> support gets just a little bit more flexible with the addition of a <code>:camelize</code> option.</li>
445
- <li>A bug in canceling callbacks from <code>before_update</code> or <code>before_create</code> was fixed.</li>
446
- <li>Rake tasks for testing databases via JDBC have been added.</li>
447
- <li>
448
- <code>validates_length_of</code> will use a custom error message with the <code>:in</code> or <code>:within</code> options (if one is supplied).</li>
449
- <li>Counts on scoped selects now work properly, so you can do things like <code>Account.scoped(:select =&gt; "DISTINCT credit_limit").count</code>.</li>
450
- <li>
451
- <code>ActiveRecord::Base#invalid?</code> now works as the opposite of <code>ActiveRecord::Base#valid?</code>.</li>
452
- </ul>
453
- <h3 id="action-controller">5 Action Controller</h3><p>Action Controller rolls out some significant changes to rendering, as well as improvements in routing and other areas, in this release.</p><h4 id="unified-rendering">5.1 Unified Rendering</h4><p><code>ActionController::Base#render</code> is a lot smarter about deciding what to render. Now you can just tell it what to render and expect to get the right results. In older versions of Rails, you often need to supply explicit information to render:</p><div class="code_container">
454
- <pre class="brush: ruby; gutter: false; toolbar: false">
455
- render :file =&gt; '/tmp/random_file.erb'
456
- render :template =&gt; 'other_controller/action'
457
- render :action =&gt; 'show'
458
-
459
- </pre>
460
- </div>
461
- <p>Now in Rails 2.3, you can just supply what you want to render:</p><div class="code_container">
462
- <pre class="brush: ruby; gutter: false; toolbar: false">
463
- render '/tmp/random_file.erb'
464
- render 'other_controller/action'
465
- render 'show'
466
- render :show
467
-
468
- </pre>
469
- </div>
470
- <p>Rails chooses between file, template, and action depending on whether there is a leading slash, an embedded slash, or no slash at all in what's to be rendered. Note that you can also use a symbol instead of a string when rendering an action. Other rendering styles (<code>:inline</code>, <code>:text</code>, <code>:update</code>, <code>:nothing</code>, <code>:json</code>, <code>:xml</code>, <code>:js</code>) still require an explicit option.</p><h4 id="application-controller-renamed">5.2 Application Controller Renamed</h4><p>If you're one of the people who has always been bothered by the special-case naming of <code>application.rb</code>, rejoice! It's been reworked to be application_controller.rb in Rails 2.3. In addition, there's a new rake task, <code>rake rails:update:application_controller</code> to do this automatically for you - and it will be run as part of the normal <code>rake rails:update</code> process.</p>
471
- <ul>
472
- <li>More Information:
473
-
474
- <ul>
475
- <li><a href="http://afreshcup.com/2008/11/17/rails-2x-the-death-of-applicationrb/">The Death of Application.rb</a></li>
476
- <li><a href="http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-more">What's New in Edge Rails: Application.rb Duality is no More</a></li>
477
- </ul>
478
- </li>
479
- </ul>
480
- <h4 id="http-digest-authentication-support">5.3 HTTP Digest Authentication Support</h4><p>Rails now has built-in support for HTTP digest authentication. To use it, you call <code>authenticate_or_request_with_http_digest</code> with a block that returns the user's password (which is then hashed and compared against the transmitted credentials):</p><div class="code_container">
481
- <pre class="brush: ruby; gutter: false; toolbar: false">
482
- class PostsController &lt; ApplicationController
483
- Users = {"dhh" =&gt; "secret"}
484
- before_filter :authenticate
485
-
486
- def secret
487
- render :text =&gt; "Password Required!"
488
- end
489
-
490
- private
491
- def authenticate
492
- realm = "Application"
493
- authenticate_or_request_with_http_digest(realm) do |name|
494
- Users[name]
495
- end
496
- end
497
- end
498
-
499
- </pre>
500
- </div>
501
-
502
- <ul>
503
- <li>Lead Contributor: <a href="http://www.kellogg-assoc.com/">Gregg Kellogg</a>
504
- </li>
505
- <li>More Information: <a href="http://ryandaigle.com/articles/2009/1/30/what-s-new-in-edge-rails-http-digest-authentication">What's New in Edge Rails: HTTP Digest Authentication</a>
506
- </li>
507
- </ul>
508
- <h4 id="more-efficient-routing">5.4 More Efficient Routing</h4><p>There are a couple of significant routing changes in Rails 2.3. The <code>formatted_</code> route helpers are gone, in favor just passing in <code>:format</code> as an option. This cuts down the route generation process by 50% for any resource - and can save a substantial amount of memory (up to 100MB on large applications). If your code uses the <code>formatted_</code> helpers, it will still work for the time being - but that behavior is deprecated and your application will be more efficient if you rewrite those routes using the new standard. Another big change is that Rails now supports multiple routing files, not just <code>routes.rb</code>. You can use <code>RouteSet#add_configuration_file</code> to bring in more routes at any time - without clearing the currently-loaded routes. While this change is most useful for Engines, you can use it in any application that needs to load routes in batches.</p>
509
- <ul>
510
- <li>Lead Contributors: <a href="http://blog.hungrymachine.com/">Aaron Batalion</a>
511
- </li>
512
- </ul>
513
- <h4 id="rack-based-lazy-loaded-sessions">5.5 Rack-based Lazy-loaded Sessions</h4><p>A big change pushed the underpinnings of Action Controller session storage down to the Rack level. This involved a good deal of work in the code, though it should be completely transparent to your Rails applications (as a bonus, some icky patches around the old CGI session handler got removed). It's still significant, though, for one simple reason: non-Rails Rack applications have access to the same session storage handlers (and therefore the same session) as your Rails applications. In addition, sessions are now lazy-loaded (in line with the loading improvements to the rest of the framework). This means that you no longer need to explicitly disable sessions if you don't want them; just don't refer to them and they won't load.</p><h4 id="mime-type-handling-changes">5.6 MIME Type Handling Changes</h4><p>There are a couple of changes to the code for handling MIME types in Rails. First, <code>MIME::Type</code> now implements the <code>=~</code> operator, making things much cleaner when you need to check for the presence of a type that has synonyms:</p><div class="code_container">
514
- <pre class="brush: ruby; gutter: false; toolbar: false">
515
- if content_type &amp;&amp; Mime::JS =~ content_type
516
- # do something cool
517
- end
518
-
519
- Mime::JS =~ "text/javascript" =&gt; true
520
- Mime::JS =~ "application/javascript" =&gt; true
521
-
522
- </pre>
523
- </div>
524
- <p>The other change is that the framework now uses the <code>Mime::JS</code> when checking for JavaScript in various spots, making it handle those alternatives cleanly.</p>
525
- <ul>
526
- <li>Lead Contributor: <a href="http://www.workingwithrails.com/person/5510-seth-fitzsimmons">Seth Fitzsimmons</a>
527
- </li>
528
- </ul>
529
- <h4 id="optimization-of-respond_to">5.7 Optimization of <code>respond_to</code>
530
- </h4><p>In some of the first fruits of the Rails-Merb team merger, Rails 2.3 includes some optimizations for the <code>respond_to</code> method, which is of course heavily used in many Rails applications to allow your controller to format results differently based on the MIME type of the incoming request. After eliminating a call to <code>method_missing</code> and some profiling and tweaking, we're seeing an 8% improvement in the number of requests per second served with a simple <code>respond_to</code> that switches between three formats. The best part? No change at all required to the code of your application to take advantage of this speedup.</p><h4 id="improved-caching-performance">5.8 Improved Caching Performance</h4><p>Rails now keeps a per-request local cache of read from the remote cache stores, cutting down on unnecessary reads and leading to better site performance. While this work was originally limited to <code>MemCacheStore</code>, it is available to any remote store than implements the required methods.</p>
531
- <ul>
532
- <li>Lead Contributor: <a href="http://www.motionstandingstill.com/">Nahum Wild</a>
533
- </li>
534
- </ul>
535
- <h4 id="localized-views">5.9 Localized Views</h4><p>Rails can now provide localized views, depending on the locale that you have set. For example, suppose you have a <code>Posts</code> controller with a <code>show</code> action. By default, this will render <code>app/views/posts/show.html.erb</code>. But if you set <code>I18n.locale = :da</code>, it will render <code>app/views/posts/show.da.html.erb</code>. If the localized template isn't present, the undecorated version will be used. Rails also includes <code>I18n#available_locales</code> and <code>I18n::SimpleBackend#available_locales</code>, which return an array of the translations that are available in the current Rails project.</p><p>In addition, you can use the same scheme to localize the rescue files in the <code>public</code> directory: <code>public/500.da.html</code> or <code>public/404.en.html</code> work, for example.</p><h4 id="partial-scoping-for-translations">5.10 Partial Scoping for Translations</h4><p>A change to the translation API makes things easier and less repetitive to write key translations within partials. If you call <code>translate(".foo")</code> from the <code>people/index.html.erb</code> template, you'll actually be calling <code>I18n.translate("people.index.foo")</code> If you don't prepend the key with a period, then the API doesn't scope, just as before.</p><h4 id="other-action-controller-changes">5.11 Other Action Controller Changes</h4>
536
- <ul>
537
- <li>ETag handling has been cleaned up a bit: Rails will now skip sending an ETag header when there's no body to the response or when sending files with <code>send_file</code>.</li>
538
- <li>The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don't generally set things up right. If that's you, you can now set <code>ActionController::Base.ip_spoofing_check = false</code> to disable the check entirely.</li>
539
- <li>
540
- <code>ActionController::Dispatcher</code> now implements its own middleware stack, which you can see by running <code>rake middleware</code>.</li>
541
- <li>Cookie sessions now have persistent session identifiers, with API compatibility with the server-side stores.</li>
542
- <li>You can now use symbols for the <code>:type</code> option of <code>send_file</code> and <code>send_data</code>, like this: <code>send_file("fabulous.png", :type =&gt; :png)</code>.</li>
543
- <li>The <code>:only</code> and <code>:except</code> options for <code>map.resources</code> are no longer inherited by nested resources.</li>
544
- <li>The bundled memcached client has been updated to version 1.6.4.99.</li>
545
- <li>The <code>expires_in</code>, <code>stale?</code>, and <code>fresh_when</code> methods now accept a <code>:public</code> option to make them work well with proxy caching.</li>
546
- <li>The <code>:requirements</code> option now works properly with additional RESTful member routes.</li>
547
- <li>Shallow routes now properly respect namespaces.</li>
548
- <li>
549
- <code>polymorphic_url</code> does a better job of handling objects with irregular plural names.</li>
550
- </ul>
551
- <h3 id="action-view">6 Action View</h3><p>Action View in Rails 2.3 picks up nested model forms, improvements to <code>render</code>, more flexible prompts for the date select helpers, and a speedup in asset caching, among other things.</p><h4 id="nested-object-forms">6.1 Nested Object Forms</h4><p>Provided the parent model accepts nested attributes for the child objects (as discussed in the Active Record section), you can create nested forms using <code>form_for</code> and <code>field_for</code>. These forms can be nested arbitrarily deep, allowing you to edit complex object hierarchies on a single view without excessive code. For example, given this model:</p><div class="code_container">
552
- <pre class="brush: ruby; gutter: false; toolbar: false">
553
- class Customer &lt; ActiveRecord::Base
554
- has_many :orders
555
-
556
- accepts_nested_attributes_for :orders, :allow_destroy =&gt; true
557
- end
558
-
559
- </pre>
560
- </div>
561
- <p>You can write this view in Rails 2.3:</p><div class="code_container">
562
- <pre class="brush: plain; gutter: false; toolbar: false">
563
- &lt;% form_for @customer do |customer_form| %&gt;
564
- &lt;div&gt;
565
- &lt;%= customer_form.label :name, 'Customer Name:' %&gt;
566
- &lt;%= customer_form.text_field :name %&gt;
567
- &lt;/div&gt;
568
-
569
- &lt;!-- Here we call fields_for on the customer_form builder instance.
570
- The block is called for each member of the orders collection. --&gt;
571
- &lt;% customer_form.fields_for :orders do |order_form| %&gt;
572
- &lt;p&gt;
573
- &lt;div&gt;
574
- &lt;%= order_form.label :number, 'Order Number:' %&gt;
575
- &lt;%= order_form.text_field :number %&gt;
576
- &lt;/div&gt;
577
-
578
- &lt;!-- The allow_destroy option in the model enables deletion of
579
- child records. --&gt;
580
- &lt;% unless order_form.object.new_record? %&gt;
581
- &lt;div&gt;
582
- &lt;%= order_form.label :_delete, 'Remove:' %&gt;
583
- &lt;%= order_form.check_box :_delete %&gt;
584
- &lt;/div&gt;
585
- &lt;% end %&gt;
586
- &lt;/p&gt;
587
- &lt;% end %&gt;
588
-
589
- &lt;%= customer_form.submit %&gt;
590
- &lt;% end %&gt;
591
-
592
- </pre>
593
- </div>
594
-
595
- <ul>
596
- <li>Lead Contributor: <a href="http://superalloy.nl/">Eloy Duran</a>
597
- </li>
598
- <li>More Information:
599
-
600
- <ul>
601
- <li><a href="http://weblog.rubyonrails.org/2009/1/26/nested-model-forms">Nested Model Forms</a></li>
602
- <li><a href="http://github.com/alloy/complex-form-examples">complex-form-examples</a></li>
603
- <li><a href="http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes">What's New in Edge Rails: Nested Object Forms</a></li>
604
- </ul>
605
- </li>
606
- </ul>
607
- <h4 id="smart-rendering-of-partials">6.2 Smart Rendering of Partials</h4><p>The render method has been getting smarter over the years, and it's even smarter now. If you have an object or a collection and an appropriate partial, and the naming matches up, you can now just render the object and things will work. For example, in Rails 2.3, these render calls will work in your view (assuming sensible naming):</p><div class="code_container">
608
- <pre class="brush: ruby; gutter: false; toolbar: false">
609
- # Equivalent of render :partial =&gt; 'articles/_article',
610
- # :object =&gt; @article
611
- render @article
612
-
613
- # Equivalent of render :partial =&gt; 'articles/_article',
614
- # :collection =&gt; @articles
615
- render @articles
616
-
617
- </pre>
618
- </div>
619
-
620
- <ul>
621
- <li>More Information: <a href="http://ryandaigle.com/articles/2008/11/20/what-s-new-in-edge-rails-render-stops-being-high-maintenance">What's New in Edge Rails: render Stops Being High-Maintenance</a>
622
- </li>
623
- </ul>
624
- <h4 id="prompts-for-date-select-helpers">6.3 Prompts for Date Select Helpers</h4><p>In Rails 2.3, you can supply custom prompts for the various date select helpers (<code>date_select</code>, <code>time_select</code>, and <code>datetime_select</code>), the same way you can with collection select helpers. You can supply a prompt string or a hash of individual prompt strings for the various components. You can also just set <code>:prompt</code> to <code>true</code> to use the custom generic prompt:</p><div class="code_container">
625
- <pre class="brush: ruby; gutter: false; toolbar: false">
626
- select_datetime(DateTime.now, :prompt =&gt; true)
627
-
628
- select_datetime(DateTime.now, :prompt =&gt; "Choose date and time")
629
-
630
- select_datetime(DateTime.now, :prompt =&gt;
631
- {:day =&gt; 'Choose day', :month =&gt; 'Choose month',
632
- :year =&gt; 'Choose year', :hour =&gt; 'Choose hour',
633
- :minute =&gt; 'Choose minute'})
634
-
635
- </pre>
636
- </div>
637
-
638
- <ul>
639
- <li>Lead Contributor: <a href="http://samoliver.com/">Sam Oliver</a>
640
- </li>
641
- </ul>
642
- <h4 id="assettag-timestamp-caching">6.4 AssetTag Timestamp Caching</h4><p>You're likely familiar with Rails' practice of adding timestamps to static asset paths as a "cache buster." This helps ensure that stale copies of things like images and stylesheets don't get served out of the user's browser cache when you change them on the server. You can now modify this behavior with the <code>cache_asset_timestamps</code> configuration option for Action View. If you enable the cache, then Rails will calculate the timestamp once when it first serves an asset, and save that value. This means fewer (expensive) file system calls to serve static assets - but it also means that you can't modify any of the assets while the server is running and expect the changes to get picked up by clients.</p><h4 id="asset-hosts-as-objects">6.5 Asset Hosts as Objects</h4><p>Asset hosts get more flexible in edge Rails with the ability to declare an asset host as a specific object that responds to a call. This allows you to implement any complex logic you need in your asset hosting.</p>
643
- <ul>
644
- <li>More Information: <a href="http://github.com/dhh/asset-hosting-with-minimum-ssl/tree/master">asset-hosting-with-minimum-ssl</a>
645
- </li>
646
- </ul>
647
- <h4 id="grouped_options_for_select-helper-method">6.6 grouped_options_for_select Helper Method</h4><p>Action View already had a bunch of helpers to aid in generating select controls, but now there's one more: <code>grouped_options_for_select</code>. This one accepts an array or hash of strings, and converts them into a string of <code>option</code> tags wrapped with <code>optgroup</code> tags. For example:</p><div class="code_container">
648
- <pre class="brush: ruby; gutter: false; toolbar: false">
649
- grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]],
650
- "Cowboy Hat", "Choose a product...")
651
-
652
- </pre>
653
- </div>
654
- <p>returns</p><div class="code_container">
655
- <pre class="brush: ruby; gutter: false; toolbar: false">
656
- &lt;option value=""&gt;Choose a product...&lt;/option&gt;
657
- &lt;optgroup label="Hats"&gt;
658
- &lt;option value="Baseball Cap"&gt;Baseball Cap&lt;/option&gt;
659
- &lt;option selected="selected" value="Cowboy Hat"&gt;Cowboy Hat&lt;/option&gt;
660
- &lt;/optgroup&gt;
661
-
662
- </pre>
663
- </div>
664
- <h4 id="disabled-option-tags-for-form-select-helpers">6.7 Disabled Option Tags for Form Select Helpers</h4><p>The form select helpers (such as <code>select</code> and <code>options_for_select</code>) now support a <code>:disabled</code> option, which can take a single value or an array of values to be disabled in the resulting tags:</p><div class="code_container">
665
- <pre class="brush: ruby; gutter: false; toolbar: false">
666
- select(:post, :category, Post::CATEGORIES, :disabled =&gt; 'private')
667
-
668
- </pre>
669
- </div>
670
- <p>returns</p><div class="code_container">
671
- <pre class="brush: xml; gutter: false; toolbar: false">
672
- &lt;select name="post[category]"&gt;
673
- &lt;option&gt;story&lt;/option&gt;
674
- &lt;option&gt;joke&lt;/option&gt;
675
- &lt;option&gt;poem&lt;/option&gt;
676
- &lt;option disabled="disabled"&gt;private&lt;/option&gt;
677
- &lt;/select&gt;
678
-
679
- </pre>
680
- </div>
681
- <p>You can also use an anonymous function to determine at runtime which options from collections will be selected and/or disabled:</p><div class="code_container">
682
- <pre class="brush: ruby; gutter: false; toolbar: false">
683
- options_from_collection_for_select(@product.sizes, :name, :id, :disabled =&gt; lambda{|size| size.out_of_stock?})
684
-
685
- </pre>
686
- </div>
687
-
688
- <ul>
689
- <li>Lead Contributor: <a href="http://tekin.co.uk/">Tekin Suleyman</a>
690
- </li>
691
- <li>More Information: <a href="http://tekin.co.uk/2009/03/new-in-rails-23-disabled-option-tags-and-lambdas-for-selecting-and-disabling-options-from-collections/">New in rails 2.3 - disabled option tags and lambdas for selecting and disabling options from collections</a>
692
- </li>
693
- </ul>
694
- <h4 id="a-note-about-template-loading">6.8 A Note About Template Loading</h4><p>Rails 2.3 includes the ability to enable or disable cached templates for any particular environment. Cached templates give you a speed boost because they don't check for a new template file when they're rendered - but they also mean that you can't replace a template "on the fly" without restarting the server.</p><p>In most cases, you'll want template caching to be turned on in production, which you can do by making a setting in your <code>production.rb</code> file:</p><div class="code_container">
695
- <pre class="brush: ruby; gutter: false; toolbar: false">
696
- config.action_view.cache_template_loading = true
697
-
698
- </pre>
699
- </div>
700
- <p>This line will be generated for you by default in a new Rails 2.3 application. If you've upgraded from an older version of Rails, Rails will default to caching templates in production and test but not in development.</p><h4 id="other-action-view-changes">6.9 Other Action View Changes</h4>
701
- <ul>
702
- <li>Token generation for CSRF protection has been simplified; now Rails uses a simple random string generated by <code>ActiveSupport::SecureRandom</code> rather than mucking around with session IDs.</li>
703
- <li>
704
- <code>auto_link</code> now properly applies options (such as <code>:target</code> and <code>:class</code>) to generated e-mail links.</li>
705
- <li>The <code>autolink</code> helper has been refactored to make it a bit less messy and more intuitive.</li>
706
- <li>
707
- <code>current_page?</code> now works properly even when there are multiple query parameters in the URL.</li>
708
- </ul>
709
- <h3 id="active-support">7 Active Support</h3><p>Active Support has a few interesting changes, including the introduction of <code>Object#try</code>.</p><h4 id="object#try">7.1 Object#try</h4><p>A lot of folks have adopted the notion of using try() to attempt operations on objects. It's especially helpful in views where you can avoid nil-checking by writing code like <code>&lt;%= @person.try(:name) %&gt;</code>. Well, now it's baked right into Rails. As implemented in Rails, it raises <code>NoMethodError</code> on private methods and always returns <code>nil</code> if the object is nil.</p>
710
- <ul>
711
- <li>More Information: <a href="http://ozmm.org/posts/try.html.">try()</a>
712
- </li>
713
- </ul>
714
- <h4 id="object#tap-backport">7.2 Object#tap Backport</h4><p><code>Object#tap</code> is an addition to <a href="http://www.ruby-doc.org/core-1.9/classes/Object.html#M000309">Ruby 1.9</a> and 1.8.7 that is similar to the <code>returning</code> method that Rails has had for a while: it yields to a block, and then returns the object that was yielded. Rails now includes code to make this available under older versions of Ruby as well.</p><h4 id="swappable-parsers-for-xmlmini">7.3 Swappable Parsers for XMLmini</h4><p>The support for XML parsing in Active Support has been made more flexible by allowing you to swap in different parsers. By default, it uses the standard REXML implementation, but you can easily specify the faster LibXML or Nokogiri implementations for your own applications, provided you have the appropriate gems installed:</p><div class="code_container">
715
- <pre class="brush: ruby; gutter: false; toolbar: false">
716
- XmlMini.backend = 'LibXML'
717
-
718
- </pre>
719
- </div>
720
-
721
- <ul>
722
- <li>Lead Contributor: <a href="http://www.movesonrails.com/">Bart ten Brinke</a>
723
- </li>
724
- <li>Lead Contributor: <a href="http://tenderlovemaking.com/">Aaron Patterson</a>
725
- </li>
726
- </ul>
727
- <h4 id="fractional-seconds-for-timewithzone">7.4 Fractional seconds for TimeWithZone</h4><p>The <code>Time</code> and <code>TimeWithZone</code> classes include an <code>xmlschema</code> method to return the time in an XML-friendly string. As of Rails 2.3, <code>TimeWithZone</code> supports the same argument for specifying the number of digits in the fractional second part of the returned string that <code>Time</code> does:</p><div class="code_container">
728
- <pre class="brush: ruby; gutter: false; toolbar: false">
729
- &gt;&gt; Time.zone.now.xmlschema(6)
730
- =&gt; "2009-01-16T13:00:06.13653Z"
731
-
732
- </pre>
733
- </div>
734
-
735
- <ul>
736
- <li>Lead Contributor: <a href="http://www.workingwithrails.com/person/13536-nicholas-dainty">Nicholas Dainty</a>
737
- </li>
738
- </ul>
739
- <h4 id="json-key-quoting">7.5 JSON Key Quoting</h4><p>If you look up the spec on the "json.org" site, you'll discover that all keys in a JSON structure must be strings, and they must be quoted with double quotes. Starting with Rails 2.3, we do the right thing here, even with numeric keys.</p><h4 id="other-active-support-changes">7.6 Other Active Support Changes</h4>
740
- <ul>
741
- <li>You can use <code>Enumerable#none?</code> to check that none of the elements match the supplied block.</li>
742
- <li>If you're using Active Support <a href="http://afreshcup.com/2008/10/19/coming-in-rails-22-delegate-prefixes/,">delegates</a> the new <code>:allow_nil</code> option lets you return <code>nil</code> instead of raising an exception when the target object is nil.</li>
743
- <li>
744
- <code>ActiveSupport::OrderedHash</code>: now implements <code>each_key</code> and <code>each_value</code>.</li>
745
- <li>
746
- <code>ActiveSupport::MessageEncryptor</code> provides a simple way to encrypt information for storage in an untrusted location (like cookies).</li>
747
- <li>Active Support's <code>from_xml</code> no longer depends on XmlSimple. Instead, Rails now includes its own XmlMini implementation, with just the functionality that it requires. This lets Rails dispense with the bundled copy of XmlSimple that it's been carting around.</li>
748
- <li>If you memoize a private method, the result will now be private.</li>
749
- <li>
750
- <code>String#parameterize</code> accepts an optional separator: <code>"Quick Brown Fox".parameterize('_') =&gt; "quick_brown_fox"</code>.</li>
751
- <li>
752
- <code>number_to_phone</code> accepts 7-digit phone numbers now.</li>
753
- <li>
754
- <code>ActiveSupport::Json.decode</code> now handles <code>\u0000</code> style escape sequences.</li>
755
- </ul>
756
- <h3 id="railties">8 Railties</h3><p>In addition to the Rack changes covered above, Railties (the core code of Rails itself) sports a number of significant changes, including Rails Metal, application templates, and quiet backtraces.</p><h4 id="rails-metal">8.1 Rails Metal</h4><p>Rails Metal is a new mechanism that provides superfast endpoints inside of your Rails applications. Metal classes bypass routing and Action Controller to give you raw speed (at the cost of all the things in Action Controller, of course). This builds on all of the recent foundation work to make Rails a Rack application with an exposed middleware stack. Metal endpoints can be loaded from your application or from plugins.</p>
757
- <ul>
758
- <li>More Information:
759
-
760
- <ul>
761
- <li><a href="http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal">Introducing Rails Metal</a></li>
762
- <li><a href="http://soylentfoo.jnewland.com/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m">Rails Metal: a micro-framework with the power of Rails</a></li>
763
- <li><a href="http://www.railsinside.com/deployment/180-metal-super-fast-endpoints-within-your-rails-apps.html">Metal: Super-fast Endpoints within your Rails Apps</a></li>
764
- <li><a href="http://ryandaigle.com/articles/2008/12/18/what-s-new-in-edge-rails-rails-metal">What's New in Edge Rails: Rails Metal</a></li>
765
- </ul>
766
- </li>
767
- </ul>
768
- <h4 id="application-templates">8.2 Application Templates</h4><p>Rails 2.3 incorporates Jeremy McAnally's <a href="http://github.com/jeremymcanally/rg/tree/master">rg</a> application generator. What this means is that we now have template-based application generation built right into Rails; if you have a set of plugins you include in every application (among many other use cases), you can just set up a template once and use it over and over again when you run the <code>rails</code> command. There's also a rake task to apply a template to an existing application:</p><div class="code_container">
769
- <pre class="brush: plain; gutter: false; toolbar: false">
770
- rake rails:template LOCATION=~/template.rb
771
-
772
- </pre>
773
- </div>
774
- <p>This will layer the changes from the template on top of whatever code the project already contains.</p>
775
- <ul>
776
- <li>Lead Contributor: <a href="http://www.jeremymcanally.com/">Jeremy McAnally</a>
777
- </li>
778
- <li>More Info:<a href="http://m.onkey.org/2008/12/4/rails-templates">Rails templates</a>
779
- </li>
780
- </ul>
781
- <h4 id="quieter-backtraces">8.3 Quieter Backtraces</h4><p>Building on Thoughtbot's <a href="https://github.com/thoughtbot/quietbacktrace">Quiet Backtrace</a> plugin, which allows you to selectively remove lines from <code>Test::Unit</code> backtraces, Rails 2.3 implements <code>ActiveSupport::BacktraceCleaner</code> and <code>Rails::BacktraceCleaner</code> in core. This supports both filters (to perform regex-based substitutions on backtrace lines) and silencers (to remove backtrace lines entirely). Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a <code>config/backtrace_silencers.rb</code> file to hold your own additions. This feature also enables prettier printing from any gem in the backtrace.</p><h4 id="faster-boot-time-in-development-mode-with-lazy-loading/autoload">8.4 Faster Boot Time in Development Mode with Lazy Loading/Autoload</h4><p>Quite a bit of work was done to make sure that bits of Rails (and its dependencies) are only brought into memory when they're actually needed. The core frameworks - Active Support, Active Record, Action Controller, Action Mailer and Action View - are now using <code>autoload</code> to lazy-load their individual classes. This work should help keep the memory footprint down and improve overall Rails performance.</p><p>You can also specify (by using the new <code>preload_frameworks</code> option) whether the core libraries should be autoloaded at startup. This defaults to <code>false</code> so that Rails autoloads itself piece-by-piece, but there are some circumstances where you still need to bring in everything at once - Passenger and JRuby both want to see all of Rails loaded together.</p><h4 id="rake-gem-task-rewrite">8.5 rake gem Task Rewrite</h4><p>The internals of the various <code>rake gem</code> tasks have been substantially revised, to make the system work better for a variety of cases. The gem system now knows the difference between development and runtime dependencies, has a more robust unpacking system, gives better information when querying for the status of gems, and is less prone to "chicken and egg" dependency issues when you're bringing things up from scratch. There are also fixes for using gem commands under JRuby and for dependencies that try to bring in external copies of gems that are already vendored.</p>
782
- <ul>
783
- <li>Lead Contributor: <a href="http://www.workingwithrails.com/person/12240-david-dollar">David Dollar</a>
784
- </li>
785
- </ul>
786
- <h4 id="other-railties-changes">8.6 Other Railties Changes</h4>
787
- <ul>
788
- <li>The instructions for updating a CI server to build Rails have been updated and expanded.</li>
789
- <li>Internal Rails testing has been switched from <code>Test::Unit::TestCase</code> to <code>ActiveSupport::TestCase</code>, and the Rails core requires Mocha to test.</li>
790
- <li>The default <code>environment.rb</code> file has been decluttered.</li>
791
- <li>The dbconsole script now lets you use an all-numeric password without crashing.</li>
792
- <li>
793
- <code>Rails.root</code> now returns a <code>Pathname</code> object, which means you can use it directly with the <code>join</code> method to <a href="http://afreshcup.com/2008/12/05/a-little-rails_root-tidiness/">clean up existing code</a> that uses <code>File.join</code>.</li>
794
- <li>Various files in /public that deal with CGI and FCGI dispatching are no longer generated in every Rails application by default (you can still get them if you need them by adding <code>--with-dispatchers</code> when you run the <code>rails</code> command, or add them later with <code>rake rails:update:generate_dispatchers</code>).</li>
795
- <li>Rails Guides have been converted from AsciiDoc to Textile markup.</li>
796
- <li>Scaffolded views and controllers have been cleaned up a bit.</li>
797
- <li>
798
- <code>script/server</code> now accepts a <code>--path</code> argument to mount a Rails application from a specific path.</li>
799
- <li>If any configured gems are missing, the gem rake tasks will skip loading much of the environment. This should solve many of the "chicken-and-egg" problems where rake gems:install couldn't run because gems were missing.</li>
800
- <li>Gems are now unpacked exactly once. This fixes issues with gems (hoe, for instance) which are packed with read-only permissions on the files.</li>
801
- </ul>
802
- <h3 id="deprecated">9 Deprecated</h3><p>A few pieces of older code are deprecated in this release:</p>
803
- <ul>
804
- <li>If you're one of the (fairly rare) Rails developers who deploys in a fashion that depends on the inspector, reaper, and spawner scripts, you'll need to know that those scripts are no longer included in core Rails. If you need them, you'll be able to pick up copies via the <a href="http://github.com/rails/irs_process_scripts/tree">irs_process_scripts</a> plugin.</li>
805
- <li>
806
- <code>render_component</code> goes from "deprecated" to "nonexistent" in Rails 2.3. If you still need it, you can install the <a href="http://github.com/rails/render_component/tree/master">render_component plugin</a>.</li>
807
- <li>Support for Rails components has been removed.</li>
808
- <li>If you were one of the people who got used to running <code>script/performance/request</code> to look at performance based on integration tests, you need to learn a new trick: that script has been removed from core Rails now. There's a new request_profiler plugin that you can install to get the exact same functionality back.</li>
809
- <li>
810
- <code>ActionController::Base#session_enabled?</code> is deprecated because sessions are lazy-loaded now.</li>
811
- <li>The <code>:digest</code> and <code>:secret</code> options to <code>protect_from_forgery</code> are deprecated and have no effect.</li>
812
- <li>Some integration test helpers have been removed. <code>response.headers["Status"]</code> and <code>headers["Status"]</code> will no longer return anything. Rack does not allow "Status" in its return headers. However you can still use the <code>status</code> and <code>status_message</code> helpers. <code>response.headers["cookie"]</code> and <code>headers["cookie"]</code> will no longer return any CGI cookies. You can inspect <code>headers["Set-Cookie"]</code> to see the raw cookie header or use the <code>cookies</code> helper to get a hash of the cookies sent to the client.</li>
813
- <li>
814
- <code>formatted_polymorphic_url</code> is deprecated. Use <code>polymorphic_url</code> with <code>:format</code> instead.</li>
815
- <li>The <code>:http_only</code> option in <code>ActionController::Response#set_cookie</code> has been renamed to <code>:httponly</code>.</li>
816
- <li>The <code>:connector</code> and <code>:skip_last_comma</code> options of <code>to_sentence</code> have been replaced by <code>:words_connnector</code>, <code>:two_words_connector</code>, and <code>:last_word_connector</code> options.</li>
817
- <li>Posting a multipart form with an empty <code>file_field</code> control used to submit an empty string to the controller. Now it submits a nil, due to differences between Rack's multipart parser and the old Rails one.</li>
818
- </ul>
819
- <h3 id="credits">10 Credits</h3><p>Release notes compiled by <a href="http://afreshcup.com">Mike Gunderloy</a>. This version of the Rails 2.3 release notes was compiled based on RC2 of Rails 2.3.</p>
820
-
821
- <h3>Feedback</h3>
822
- <p>
823
- You're encouraged to help improve the quality of this guide.
824
- </p>
825
- <p>
826
- Please contribute if you see any typos or factual errors.
827
- 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.
828
- </p>
829
- <p>
830
- You may also find incomplete content, or stuff that is not up to date.
831
- Please do add any missing documentation for master. Make sure to check
832
- <a href="http://edgeguides.rubyonrails.org">Edge Guides</a> first to verify
833
- if the issues are already fixed or not on the master branch.
834
- Check the <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
835
- for style and conventions.
836
- </p>
837
- <p>
838
- If for whatever reason you spot something to fix but cannot patch it yourself, please
839
- <a href="https://github.com/rails/rails/issues">open an issue</a>.
840
- </p>
841
- <p>And last but not least, any kind of discussion regarding Ruby on Rails
842
- documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
843
- </p>
844
- </div>
845
- </div>
846
- </div>
847
-
848
- <hr class="hide" />
849
- <div id="footer">
850
- <div class="wrapper">
851
- <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>
852
- <p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
853
-
854
- </div>
855
- </div>
856
-
857
- <script type="text/javascript" src="javascripts/jquery.min.js"></script>
858
- <script type="text/javascript" src="javascripts/responsive-tables.js"></script>
859
- <script type="text/javascript" src="javascripts/guides.js"></script>
860
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
861
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
862
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
863
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
864
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
865
- <script type="text/javascript">
866
- SyntaxHighlighter.all();
867
- $(guidesIndex.bind);
868
- </script>
869
- </body>
870
- </html>