rails 4.2.0.beta3 → 4.2.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -7
  3. data/guides/output/2_2_release_notes.html +724 -0
  4. data/guides/output/2_3_release_notes.html +870 -0
  5. data/guides/output/3_0_release_notes.html +773 -0
  6. data/guides/output/3_1_release_notes.html +740 -0
  7. data/guides/output/3_2_release_notes.html +797 -0
  8. data/guides/output/4_0_release_notes.html +523 -0
  9. data/guides/output/4_1_release_notes.html +806 -0
  10. data/guides/output/4_2_release_notes.html +728 -0
  11. data/guides/output/Gemfile +6 -0
  12. data/guides/output/_license.html +226 -0
  13. data/guides/output/_welcome.html +233 -0
  14. data/guides/output/action_controller_overview.html +1335 -0
  15. data/guides/output/action_mailer_basics.html +928 -0
  16. data/guides/output/action_view_overview.html +1509 -0
  17. data/guides/output/active_job_basics.html +546 -0
  18. data/guides/output/active_model_basics.html +438 -0
  19. data/guides/output/active_record_basics.html +594 -0
  20. data/guides/output/active_record_callbacks.html +592 -0
  21. data/guides/output/active_record_migrations.html +1123 -0
  22. data/guides/output/active_record_postgresql.html +675 -0
  23. data/guides/output/active_record_querying.html +1796 -0
  24. data/guides/output/active_record_validations.html +1301 -0
  25. data/guides/output/active_support_core_extensions.html +3450 -0
  26. data/guides/output/active_support_instrumentation.html +1121 -0
  27. data/guides/output/api_documentation_guidelines.html +498 -0
  28. data/guides/output/asset_pipeline.html +1167 -0
  29. data/guides/output/association_basics.html +2086 -0
  30. data/guides/output/caching_with_rails.html +553 -0
  31. data/guides/output/command_line.html +791 -0
  32. data/guides/output/configuring.html +1055 -0
  33. data/guides/output/contributing_to_ruby_on_rails.html +657 -0
  34. data/guides/output/credits.html +284 -0
  35. data/guides/output/debugging_rails_applications.html +1014 -0
  36. data/guides/output/development_dependencies_install.html +478 -0
  37. data/guides/output/engines.html +1438 -0
  38. data/guides/output/form_helpers.html +1074 -0
  39. data/guides/output/generators.html +838 -0
  40. data/guides/output/getting_started.html +2092 -0
  41. data/guides/output/i18n.html +1198 -0
  42. data/guides/output/images/akshaysurve.jpg +0 -0
  43. data/guides/output/images/belongs_to.png +0 -0
  44. data/guides/output/images/book_icon.gif +0 -0
  45. data/guides/output/images/bullet.gif +0 -0
  46. data/guides/output/images/chapters_icon.gif +0 -0
  47. data/guides/output/images/check_bullet.gif +0 -0
  48. data/guides/output/images/credits_pic_blank.gif +0 -0
  49. data/guides/output/images/csrf.png +0 -0
  50. data/guides/output/images/edge_badge.png +0 -0
  51. data/guides/output/images/favicon.ico +0 -0
  52. data/guides/output/images/feature_tile.gif +0 -0
  53. data/guides/output/images/footer_tile.gif +0 -0
  54. data/guides/output/images/fxn.png +0 -0
  55. data/guides/output/images/getting_started/article_with_comments.png +0 -0
  56. data/guides/output/images/getting_started/challenge.png +0 -0
  57. data/guides/output/images/getting_started/confirm_dialog.png +0 -0
  58. data/guides/output/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  59. data/guides/output/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
  60. data/guides/output/images/getting_started/form_with_errors.png +0 -0
  61. data/guides/output/images/getting_started/index_action_with_edit_link.png +0 -0
  62. data/guides/output/images/getting_started/new_article.png +0 -0
  63. data/guides/output/images/getting_started/new_post.png +0 -0
  64. data/guides/output/images/getting_started/post_with_comments.png +0 -0
  65. data/guides/output/images/getting_started/rails_welcome.png +0 -0
  66. data/guides/output/images/getting_started/routing_error_no_controller.png +0 -0
  67. data/guides/output/images/getting_started/routing_error_no_route_matches.png +0 -0
  68. data/guides/output/images/getting_started/show_action_for_articles.png +0 -0
  69. data/guides/output/images/getting_started/show_action_for_posts.png +0 -0
  70. data/guides/output/images/getting_started/template_is_missing_articles_new.png +0 -0
  71. data/guides/output/images/getting_started/template_is_missing_posts_new.png +0 -0
  72. data/guides/output/images/getting_started/undefined_method_post_path.png +0 -0
  73. data/guides/output/images/getting_started/unknown_action_create_for_articles.png +0 -0
  74. data/guides/output/images/getting_started/unknown_action_create_for_posts.png +0 -0
  75. data/guides/output/images/getting_started/unknown_action_new_for_articles.png +0 -0
  76. data/guides/output/images/getting_started/unknown_action_new_for_posts.png +0 -0
  77. data/guides/output/images/grey_bullet.gif +0 -0
  78. data/guides/output/images/habtm.png +0 -0
  79. data/guides/output/images/has_many.png +0 -0
  80. data/guides/output/images/has_many_through.png +0 -0
  81. data/guides/output/images/has_one.png +0 -0
  82. data/guides/output/images/has_one_through.png +0 -0
  83. data/guides/output/images/header_backdrop.png +0 -0
  84. data/guides/output/images/header_tile.gif +0 -0
  85. data/guides/output/images/i18n/demo_html_safe.png +0 -0
  86. data/guides/output/images/i18n/demo_localized_pirate.png +0 -0
  87. data/guides/output/images/i18n/demo_translated_en.png +0 -0
  88. data/guides/output/images/i18n/demo_translated_pirate.png +0 -0
  89. data/guides/output/images/i18n/demo_translation_missing.png +0 -0
  90. data/guides/output/images/i18n/demo_untranslated.png +0 -0
  91. data/guides/output/images/icons/README +5 -0
  92. data/guides/output/images/icons/callouts/1.png +0 -0
  93. data/guides/output/images/icons/callouts/10.png +0 -0
  94. data/guides/output/images/icons/callouts/11.png +0 -0
  95. data/guides/output/images/icons/callouts/12.png +0 -0
  96. data/guides/output/images/icons/callouts/13.png +0 -0
  97. data/guides/output/images/icons/callouts/14.png +0 -0
  98. data/guides/output/images/icons/callouts/15.png +0 -0
  99. data/guides/output/images/icons/callouts/2.png +0 -0
  100. data/guides/output/images/icons/callouts/3.png +0 -0
  101. data/guides/output/images/icons/callouts/4.png +0 -0
  102. data/guides/output/images/icons/callouts/5.png +0 -0
  103. data/guides/output/images/icons/callouts/6.png +0 -0
  104. data/guides/output/images/icons/callouts/7.png +0 -0
  105. data/guides/output/images/icons/callouts/8.png +0 -0
  106. data/guides/output/images/icons/callouts/9.png +0 -0
  107. data/guides/output/images/icons/caution.png +0 -0
  108. data/guides/output/images/icons/example.png +0 -0
  109. data/guides/output/images/icons/home.png +0 -0
  110. data/guides/output/images/icons/important.png +0 -0
  111. data/guides/output/images/icons/next.png +0 -0
  112. data/guides/output/images/icons/note.png +0 -0
  113. data/guides/output/images/icons/prev.png +0 -0
  114. data/guides/output/images/icons/tip.png +0 -0
  115. data/guides/output/images/icons/up.png +0 -0
  116. data/guides/output/images/icons/warning.png +0 -0
  117. data/guides/output/images/nav_arrow.gif +0 -0
  118. data/guides/output/images/oscardelben.jpg +0 -0
  119. data/guides/output/images/polymorphic.png +0 -0
  120. data/guides/output/images/radar.png +0 -0
  121. data/guides/output/images/rails4_features.png +0 -0
  122. data/guides/output/images/rails_guides_kindle_cover.jpg +0 -0
  123. data/guides/output/images/rails_guides_logo.gif +0 -0
  124. data/guides/output/images/rails_logo_remix.gif +0 -0
  125. data/guides/output/images/session_fixation.png +0 -0
  126. data/guides/output/images/tab_grey.gif +0 -0
  127. data/guides/output/images/tab_info.gif +0 -0
  128. data/guides/output/images/tab_note.gif +0 -0
  129. data/guides/output/images/tab_red.gif +0 -0
  130. data/guides/output/images/tab_yellow.gif +0 -0
  131. data/guides/output/images/tab_yellow.png +0 -0
  132. data/guides/output/images/vijaydev.jpg +0 -0
  133. data/guides/output/index.html +354 -0
  134. data/guides/output/initialization.html +876 -0
  135. data/guides/output/javascripts/guides.js +59 -0
  136. data/guides/output/javascripts/jquery.min.js +4 -0
  137. data/guides/output/javascripts/responsive-tables.js +43 -0
  138. data/guides/output/javascripts/syntaxhighlighter/shBrushAS3.js +59 -0
  139. data/guides/output/javascripts/syntaxhighlighter/shBrushAppleScript.js +75 -0
  140. data/guides/output/javascripts/syntaxhighlighter/shBrushBash.js +59 -0
  141. data/guides/output/javascripts/syntaxhighlighter/shBrushCSharp.js +65 -0
  142. data/guides/output/javascripts/syntaxhighlighter/shBrushColdFusion.js +100 -0
  143. data/guides/output/javascripts/syntaxhighlighter/shBrushCpp.js +97 -0
  144. data/guides/output/javascripts/syntaxhighlighter/shBrushCss.js +91 -0
  145. data/guides/output/javascripts/syntaxhighlighter/shBrushDelphi.js +55 -0
  146. data/guides/output/javascripts/syntaxhighlighter/shBrushDiff.js +41 -0
  147. data/guides/output/javascripts/syntaxhighlighter/shBrushErlang.js +52 -0
  148. data/guides/output/javascripts/syntaxhighlighter/shBrushGroovy.js +67 -0
  149. data/guides/output/javascripts/syntaxhighlighter/shBrushJScript.js +52 -0
  150. data/guides/output/javascripts/syntaxhighlighter/shBrushJava.js +57 -0
  151. data/guides/output/javascripts/syntaxhighlighter/shBrushJavaFX.js +58 -0
  152. data/guides/output/javascripts/syntaxhighlighter/shBrushPerl.js +72 -0
  153. data/guides/output/javascripts/syntaxhighlighter/shBrushPhp.js +88 -0
  154. data/guides/output/javascripts/syntaxhighlighter/shBrushPlain.js +33 -0
  155. data/guides/output/javascripts/syntaxhighlighter/shBrushPowerShell.js +74 -0
  156. data/guides/output/javascripts/syntaxhighlighter/shBrushPython.js +64 -0
  157. data/guides/output/javascripts/syntaxhighlighter/shBrushRuby.js +55 -0
  158. data/guides/output/javascripts/syntaxhighlighter/shBrushSass.js +94 -0
  159. data/guides/output/javascripts/syntaxhighlighter/shBrushScala.js +51 -0
  160. data/guides/output/javascripts/syntaxhighlighter/shBrushSql.js +66 -0
  161. data/guides/output/javascripts/syntaxhighlighter/shBrushVb.js +56 -0
  162. data/guides/output/javascripts/syntaxhighlighter/shBrushXml.js +69 -0
  163. data/guides/output/javascripts/syntaxhighlighter/shCore.js +17 -0
  164. data/guides/output/layout.html +448 -0
  165. data/guides/output/layouts_and_rendering.html +1541 -0
  166. data/guides/output/maintenance_policy.html +257 -0
  167. data/guides/output/migrations.html +1360 -0
  168. data/guides/output/nested_model_forms.html +412 -0
  169. data/guides/output/plugins.html +644 -0
  170. data/guides/output/rails_application_templates.html +450 -0
  171. data/guides/output/rails_on_rack.html +547 -0
  172. data/guides/output/routing.html +1631 -0
  173. data/guides/output/ruby_on_rails_guides_guidelines.html +329 -0
  174. data/guides/output/security.html +935 -0
  175. data/guides/output/stylesheets/fixes.css +16 -0
  176. data/guides/output/stylesheets/kindle.css +11 -0
  177. data/guides/output/stylesheets/main.css +713 -0
  178. data/guides/output/stylesheets/print.css +52 -0
  179. data/guides/output/stylesheets/reset.css +43 -0
  180. data/guides/output/stylesheets/responsive-tables.css +50 -0
  181. data/guides/output/stylesheets/style.css +13 -0
  182. data/guides/output/stylesheets/syntaxhighlighter/shCore.css +226 -0
  183. data/guides/output/stylesheets/syntaxhighlighter/shCoreDefault.css +328 -0
  184. data/guides/output/stylesheets/syntaxhighlighter/shCoreDjango.css +331 -0
  185. data/guides/output/stylesheets/syntaxhighlighter/shCoreEclipse.css +339 -0
  186. data/guides/output/stylesheets/syntaxhighlighter/shCoreEmacs.css +324 -0
  187. data/guides/output/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +328 -0
  188. data/guides/output/stylesheets/syntaxhighlighter/shCoreMDUltra.css +324 -0
  189. data/guides/output/stylesheets/syntaxhighlighter/shCoreMidnight.css +324 -0
  190. data/guides/output/stylesheets/syntaxhighlighter/shCoreRDark.css +324 -0
  191. data/guides/output/stylesheets/syntaxhighlighter/shThemeDefault.css +117 -0
  192. data/guides/output/stylesheets/syntaxhighlighter/shThemeDjango.css +120 -0
  193. data/guides/output/stylesheets/syntaxhighlighter/shThemeEclipse.css +128 -0
  194. data/guides/output/stylesheets/syntaxhighlighter/shThemeEmacs.css +113 -0
  195. data/guides/output/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +117 -0
  196. data/guides/output/stylesheets/syntaxhighlighter/shThemeMDUltra.css +113 -0
  197. data/guides/output/stylesheets/syntaxhighlighter/shThemeMidnight.css +113 -0
  198. data/guides/output/stylesheets/syntaxhighlighter/shThemeRDark.css +113 -0
  199. data/guides/output/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +116 -0
  200. data/guides/output/testing.html +1350 -0
  201. data/guides/output/upgrading_ruby_on_rails.html +1135 -0
  202. data/guides/output/working_with_javascript_in_rails.html +587 -0
  203. data/guides/source/4_0_release_notes.md +2 -2
  204. data/guides/source/4_2_release_notes.md +9 -2
  205. data/guides/source/action_controller_overview.md +3 -1
  206. data/guides/source/action_mailer_basics.md +1 -2
  207. data/guides/source/active_job_basics.md +25 -2
  208. data/guides/source/active_model_basics.md +350 -19
  209. data/guides/source/active_record_basics.md +2 -2
  210. data/guides/source/active_record_migrations.md +1 -1
  211. data/guides/source/active_record_validations.md +12 -4
  212. data/guides/source/active_support_core_extensions.md +7 -9
  213. data/guides/source/active_support_instrumentation.md +2 -0
  214. data/guides/source/association_basics.md +7 -7
  215. data/guides/source/configuring.md +24 -0
  216. data/guides/source/contributing_to_ruby_on_rails.md +1 -1
  217. data/guides/source/credits.html.erb +1 -1
  218. data/guides/source/documents.yaml +5 -0
  219. data/guides/source/engines.md +2 -2
  220. data/guides/source/form_helpers.md +6 -0
  221. data/guides/source/i18n.md +6 -9
  222. data/guides/source/layouts_and_rendering.md +1 -1
  223. data/guides/source/plugins.md +2 -2
  224. data/guides/source/rails_on_rack.md +4 -0
  225. data/guides/source/testing.md +1 -0
  226. data/guides/source/upgrading_ruby_on_rails.md +5 -5
  227. metadata +227 -27
@@ -0,0 +1,740 @@
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 3.1 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 3.1 Release Notes</h2><p>Highlights in Rails 3.1:</p>
165
+ <ul>
166
+ <li>Streaming</li>
167
+ <li>Reversible Migrations</li>
168
+ <li>Assets Pipeline</li>
169
+ <li>jQuery as the default JavaScript library</li>
170
+ </ul>
171
+ <p>This release notes cover the major changes, but don&#39;t include every little bug fix and change. If you want to see everything, check out the <a href="https://github.com/rails/rails/commits/master">list of commits</a> in the main Rails repository on GitHub.</p>
172
+
173
+ <div id="subCol">
174
+ <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
175
+ <ol class="chapters">
176
+ <li>
177
+ <a href="#upgrading-to-rails-3.1">Upgrading to Rails 3.1</a>
178
+
179
+ <ul>
180
+ <li><a href="#rails-3.1-requires-at-least-ruby-1.8.7">Rails 3.1 requires at least Ruby 1.8.7</a></li>
181
+ <li><a href="#what-to-update-in-your-apps">What to update in your apps</a></li>
182
+ </ul>
183
+ </li>
184
+ <li>
185
+ <a href="#creating-a-rails-3.1-application">Creating a Rails 3.1 application</a>
186
+
187
+ <ul>
188
+ <li><a href="#vendoring-gems">Vendoring Gems</a></li>
189
+ <li><a href="#living-on-the-edge">Living on the Edge</a></li>
190
+ </ul>
191
+ </li>
192
+ <li>
193
+ <a href="#rails-architectural-changes">Rails Architectural Changes</a>
194
+
195
+ <ul>
196
+ <li><a href="#assets-pipeline">Assets Pipeline</a></li>
197
+ <li><a href="#http-streaming">HTTP Streaming</a></li>
198
+ <li><a href="#default-js-library-is-now-jquery">Default JS library is now jQuery</a></li>
199
+ <li><a href="#identity-map">Identity Map</a></li>
200
+ </ul>
201
+ </li>
202
+ <li><a href="#railties">Railties</a></li>
203
+ <li>
204
+ <a href="#action-pack">Action Pack</a>
205
+
206
+ <ul>
207
+ <li><a href="#action-controller">Action Controller</a></li>
208
+ <li><a href="#action-dispatch">Action Dispatch</a></li>
209
+ <li><a href="#action-view">Action View</a></li>
210
+ </ul>
211
+ </li>
212
+ <li><a href="#active-record">Active Record</a></li>
213
+ <li><a href="#active-model">Active Model</a></li>
214
+ <li><a href="#active-resource">Active Resource</a></li>
215
+ <li><a href="#active-support">Active Support</a></li>
216
+ <li><a href="#credits">Credits</a></li>
217
+ </ol>
218
+
219
+ </div>
220
+
221
+ </div>
222
+ </div>
223
+
224
+ <div id="container">
225
+ <div class="wrapper">
226
+ <div id="mainCol">
227
+ <h3 id="upgrading-to-rails-3.1">1 Upgrading to Rails 3.1</h3><p>If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 3 in case you haven't and make sure your application still runs as expected before attempting to update to Rails 3.1. Then take heed of the following changes:</p><h4 id="rails-3.1-requires-at-least-ruby-1.8.7">1.1 Rails 3.1 requires at least Ruby 1.8.7</h4><p>Rails 3.1 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.1 is also compatible with Ruby 1.9.2.</p><div class="info"><p>Note that Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02 though. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults, so if you want to use 1.9.x jump on 1.9.2 for smooth sailing.</p></div><h4 id="what-to-update-in-your-apps">1.2 What to update in your apps</h4><p>The following changes are meant for upgrading your application to Rails 3.1.3, the latest 3.1.x version of Rails.</p><h5 id="gemfile">1.2.1 Gemfile</h5><p>Make the following changes to your <code>Gemfile</code>.</p><div class="code_container">
228
+ <pre class="brush: ruby; gutter: false; toolbar: false">
229
+ gem 'rails', '= 3.1.3'
230
+ gem 'mysql2'
231
+
232
+ # Needed for the new asset pipeline
233
+ group :assets do
234
+ gem 'sass-rails', "~&gt; 3.1.5"
235
+ gem 'coffee-rails', "~&gt; 3.1.1"
236
+ gem 'uglifier', "&gt;= 1.0.3"
237
+ end
238
+
239
+ # jQuery is the default JavaScript library in Rails 3.1
240
+ gem 'jquery-rails'
241
+
242
+ </pre>
243
+ </div>
244
+ <h5 id="config/application.rb">1.2.2 config/application.rb</h5>
245
+ <ul>
246
+ <li>
247
+ <p>The asset pipeline requires the following additions:</p>
248
+ <div class="code_container">
249
+ <pre class="brush: ruby; gutter: false; toolbar: false">
250
+ config.assets.enabled = true
251
+ config.assets.version = '1.0'
252
+
253
+ </pre>
254
+ </div>
255
+ </li>
256
+ <li>
257
+ <p>If your application is using the "/assets" route for a resource you may want change the prefix used for assets to avoid conflicts:</p>
258
+ <div class="code_container">
259
+ <pre class="brush: ruby; gutter: false; toolbar: false">
260
+ # Defaults to '/assets'
261
+ config.assets.prefix = '/asset-files'
262
+
263
+ </pre>
264
+ </div>
265
+ </li>
266
+ </ul>
267
+ <h5 id="config/environments/development.rb">1.2.3 config/environments/development.rb</h5>
268
+ <ul>
269
+ <li><p>Remove the RJS setting <code>config.action_view.debug_rjs = true</code>.</p></li>
270
+ <li>
271
+ <p>Add the following, if you enable the asset pipeline.</p>
272
+ <div class="code_container">
273
+ <pre class="brush: ruby; gutter: false; toolbar: false">
274
+ # Do not compress assets
275
+ config.assets.compress = false
276
+
277
+ # Expands the lines which load the assets
278
+ config.assets.debug = true
279
+
280
+ </pre>
281
+ </div>
282
+ </li>
283
+ </ul>
284
+ <h5 id="config/environments/production.rb">1.2.4 config/environments/production.rb</h5>
285
+ <ul>
286
+ <li>
287
+ <p>Again, most of the changes below are for the asset pipeline. You can read more about these in the <a href="asset_pipeline.html">Asset Pipeline</a> guide.</p>
288
+ <div class="code_container">
289
+ <pre class="brush: ruby; gutter: false; toolbar: false">
290
+ # Compress JavaScripts and CSS
291
+ config.assets.compress = true
292
+
293
+ # Don't fallback to assets pipeline if a precompiled asset is missed
294
+ config.assets.compile = false
295
+
296
+ # Generate digests for assets URLs
297
+ config.assets.digest = true
298
+
299
+ # Defaults to Rails.root.join("public/assets")
300
+ # config.assets.manifest = YOUR_PATH
301
+
302
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
303
+ # config.assets.precompile `= %w( search.js )
304
+
305
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
306
+ # config.force_ssl = true
307
+
308
+ </pre>
309
+ </div>
310
+ </li>
311
+ </ul>
312
+ <h5 id="config/environments/test.rb">1.2.5 config/environments/test.rb</h5><div class="code_container">
313
+ <pre class="brush: ruby; gutter: false; toolbar: false">
314
+ # Configure static asset server for tests with Cache-Control for performance
315
+ config.serve_static_assets = true
316
+ config.static_cache_control = "public, max-age=3600"
317
+
318
+ </pre>
319
+ </div>
320
+ <h5 id="config/initializers/wrap_parameters.rb">1.2.6 config/initializers/wrap_parameters.rb</h5>
321
+ <ul>
322
+ <li>
323
+ <p>Add this file with the following contents, if you wish to wrap parameters into a nested hash. This is on by default in new applications.</p>
324
+ <div class="code_container">
325
+ <pre class="brush: ruby; gutter: false; toolbar: false">
326
+ # Be sure to restart your server when you modify this file.
327
+ # This file contains settings for ActionController::ParamsWrapper which
328
+ # is enabled by default.
329
+
330
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
331
+ ActiveSupport.on_load(:action_controller) do
332
+ wrap_parameters :format =&gt; [:json]
333
+ end
334
+
335
+ # Disable root element in JSON by default.
336
+ ActiveSupport.on_load(:active_record) do
337
+ self.include_root_in_json = false
338
+ end
339
+
340
+ </pre>
341
+ </div>
342
+ </li>
343
+ </ul>
344
+ <h5 id="remove-:cache-and-:concat-options-in-asset-helpers-references-in-views">1.2.7 Remove :cache and :concat options in asset helpers references in views</h5>
345
+ <ul>
346
+ <li>With the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from your views.</li>
347
+ </ul>
348
+ <h3 id="creating-a-rails-3.1-application">2 Creating a Rails 3.1 application</h3><div class="code_container">
349
+ <pre class="brush: plain; gutter: false; toolbar: false">
350
+ # You should have the 'rails' RubyGem installed
351
+ $ rails new myapp
352
+ $ cd myapp
353
+
354
+ </pre>
355
+ </div>
356
+ <h4 id="vendoring-gems">2.1 Vendoring Gems</h4><p>Rails now uses a <code>Gemfile</code> in the application root to determine the gems you require for your application to start. This <code>Gemfile</code> is processed by the <a href="https://github.com/carlhuda/bundler">Bundler</a> gem, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.</p><p>More information: - <a href="http://gembundler.com">bundler homepage</a></p><h4 id="living-on-the-edge">2.2 Living on the Edge</h4><p><code>Bundler</code> and <code>Gemfile</code> makes freezing your Rails application easy as pie with the new dedicated <code>bundle</code> command. If you want to bundle straight from the Git repository, you can pass the <code>--edge</code> flag:</p><div class="code_container">
357
+ <pre class="brush: plain; gutter: false; toolbar: false">
358
+ $ rails new myapp --edge
359
+
360
+ </pre>
361
+ </div>
362
+ <p>If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the <code>--dev</code> flag:</p><div class="code_container">
363
+ <pre class="brush: plain; gutter: false; toolbar: false">
364
+ $ ruby /path/to/rails/railties/bin/rails new myapp --dev
365
+
366
+ </pre>
367
+ </div>
368
+ <h3 id="rails-architectural-changes">3 Rails Architectural Changes</h3><h4 id="assets-pipeline">3.1 Assets Pipeline</h4><p>The major change in Rails 3.1 is the Assets Pipeline. It makes CSS and JavaScript first-class code citizens and enables proper organization, including use in plugins and engines.</p><p>The assets pipeline is powered by <a href="https://github.com/sstephenson/sprockets">Sprockets</a> and is covered in the <a href="asset_pipeline.html">Asset Pipeline</a> guide.</p><h4 id="http-streaming">3.2 HTTP Streaming</h4><p>HTTP Streaming is another change that is new in Rails 3.1. This lets the browser download your stylesheets and JavaScript files while the server is still generating the response. This requires Ruby 1.9.2, is opt-in and requires support from the web server as well, but the popular combo of NGINX and Unicorn is ready to take advantage of it.</p><h4 id="default-js-library-is-now-jquery">3.3 Default JS library is now jQuery</h4><p>jQuery is the default JavaScript library that ships with Rails 3.1. But if you use Prototype, it's simple to switch.</p><div class="code_container">
369
+ <pre class="brush: plain; gutter: false; toolbar: false">
370
+ $ rails new myapp -j prototype
371
+
372
+ </pre>
373
+ </div>
374
+ <h4 id="identity-map">3.4 Identity Map</h4><p>Active Record has an Identity Map in Rails 3.1. An identity map keeps previously instantiated records and returns the object associated with the record if accessed again. The identity map is created on a per-request basis and is flushed at request completion.</p><p>Rails 3.1 comes with the identity map turned off by default.</p><h3 id="railties">4 Railties</h3>
375
+ <ul>
376
+ <li><p>jQuery is the new default JavaScript library.</p></li>
377
+ <li><p>jQuery and Prototype are no longer vendored and is provided from now on by the jquery-rails and prototype-rails gems.</p></li>
378
+ <li><p>The application generator accepts an option <code>-j</code> which can be an arbitrary string. If passed "foo", the gem "foo-rails" is added to the <code>Gemfile</code>, and the application JavaScript manifest requires "foo" and "foo_ujs". Currently only "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline.</p></li>
379
+ <li><p>Generating an application or a plugin runs <code>bundle install</code> unless <code>--skip-gemfile</code> or <code>--skip-bundle</code> is specified.</p></li>
380
+ <li><p>The controller and resource generators will now automatically produce asset stubs (this can be turned off with <code>--skip-assets</code>). These stubs will use CoffeeScript and Sass, if those libraries are available.</p></li>
381
+ <li><p>Scaffold and app generators use the Ruby 1.9 style hash when running on Ruby 1.9. To generate old style hash, <code>--old-style-hash</code> can be passed.</p></li>
382
+ <li><p>Scaffold controller generator creates format block for JSON instead of XML.</p></li>
383
+ <li><p>Active Record logging is directed to STDOUT and shown inline in the console.</p></li>
384
+ <li><p>Added <code>config.force_ssl</code> configuration which loads <code>Rack::SSL</code> middleware and force all requests to be under HTTPS protocol.</p></li>
385
+ <li><p>Added <code>rails plugin new</code> command which generates a Rails plugin with gemspec, tests and a dummy application for testing.</p></li>
386
+ <li><p>Added <code>Rack::Etag</code> and <code>Rack::ConditionalGet</code> to the default middleware stack.</p></li>
387
+ <li><p>Added <code>Rack::Cache</code> to the default middleware stack.</p></li>
388
+ <li><p>Engines received a major update - You can mount them at any path, enable assets, run generators etc.</p></li>
389
+ </ul>
390
+ <h3 id="action-pack">5 Action Pack</h3><h4 id="action-controller">5.1 Action Controller</h4>
391
+ <ul>
392
+ <li><p>A warning is given out if the CSRF token authenticity cannot be verified.</p></li>
393
+ <li><p>Specify <code>force_ssl</code> in a controller to force the browser to transfer data via HTTPS protocol on that particular controller. To limit to specific actions, <code>:only</code> or <code>:except</code> can be used.</p></li>
394
+ <li><p>Sensitive query string parameters specified in <code>config.filter_parameters</code> will now be filtered out from the request paths in the log.</p></li>
395
+ <li><p>URL parameters which return <code>nil</code> for <code>to_param</code> are now removed from the query string.</p></li>
396
+ <li><p>Added <code>ActionController::ParamsWrapper</code> to wrap parameters into a nested hash, and will be turned on for JSON request in new applications by default. This can be customized in <code>config/initializers/wrap_parameters.rb</code>.</p></li>
397
+ <li><p>Added <code>config.action_controller.include_all_helpers</code>. By default <code>helper :all</code> is done in <code>ActionController::Base</code>, which includes all the helpers by default. Setting <code>include_all_helpers</code> to <code>false</code> will result in including only application_helper and the helper corresponding to controller (like foo_helper for foo_controller).</p></li>
398
+ <li><p><code>url_for</code> and named url helpers now accept <code>:subdomain</code> and <code>:domain</code> as options.</p></li>
399
+ <li>
400
+ <p>Added <code>Base.http_basic_authenticate_with</code> to do simple http basic authentication with a single class method call.</p>
401
+ <div class="code_container">
402
+ <pre class="brush: ruby; gutter: false; toolbar: false">
403
+ class PostsController &lt; ApplicationController
404
+ USER_NAME, PASSWORD = "dhh", "secret"
405
+
406
+ before_filter :authenticate, :except =&gt; [ :index ]
407
+
408
+ def index
409
+ render :text =&gt; "Everyone can see me!"
410
+ end
411
+
412
+ def edit
413
+ render :text =&gt; "I'm only accessible if you know the password"
414
+ end
415
+
416
+ private
417
+ def authenticate
418
+ authenticate_or_request_with_http_basic do |user_name, password|
419
+ user_name == USER_NAME &amp;&amp; password == PASSWORD
420
+ end
421
+ end
422
+ end
423
+
424
+ </pre>
425
+ </div>
426
+ <p>..can now be written as</p>
427
+ <div class="code_container">
428
+ <pre class="brush: ruby; gutter: false; toolbar: false">
429
+ class PostsController &lt; ApplicationController
430
+ http_basic_authenticate_with :name =&gt; "dhh", :password =&gt; "secret", :except =&gt; :index
431
+
432
+ def index
433
+ render :text =&gt; "Everyone can see me!"
434
+ end
435
+
436
+ def edit
437
+ render :text =&gt; "I'm only accessible if you know the password"
438
+ end
439
+ end
440
+
441
+ </pre>
442
+ </div>
443
+ </li>
444
+ <li>
445
+ <p>Added streaming support, you can enable it with:</p>
446
+ <div class="code_container">
447
+ <pre class="brush: ruby; gutter: false; toolbar: false">
448
+ class PostsController &lt; ActionController::Base
449
+ stream
450
+ end
451
+
452
+ </pre>
453
+ </div>
454
+ <p>You can restrict it to some actions by using <code>:only</code> or <code>:except</code>. Please read the docs at <a href="http://api.rubyonrails.org/v3.1.0/classes/ActionController/Streaming.html"><code>ActionController::Streaming</code></a> for more information.</p>
455
+ </li>
456
+ <li><p>The redirect route method now also accepts a hash of options which will only change the parts of the url in question, or an object which responds to call, allowing for redirects to be reused.</p></li>
457
+ </ul>
458
+ <h4 id="action-dispatch">5.2 Action Dispatch</h4>
459
+ <ul>
460
+ <li><p><code>config.action_dispatch.x_sendfile_header</code> now defaults to <code>nil</code> and <code>config/environments/production.rb</code> doesn't set any particular value for it. This allows servers to set it through <code>X-Sendfile-Type</code>.</p></li>
461
+ <li><p><code>ActionDispatch::MiddlewareStack</code> now uses composition over inheritance and is no longer an array.</p></li>
462
+ <li><p>Added <code>ActionDispatch::Request.ignore_accept_header</code> to ignore accept headers.</p></li>
463
+ <li><p>Added <code>Rack::Cache</code> to the default stack.</p></li>
464
+ <li><p>Moved etag responsibility from <code>ActionDispatch::Response</code> to the middleware stack.</p></li>
465
+ <li><p>Rely on <code>Rack::Session</code> stores API for more compatibility across the Ruby world. This is backwards incompatible since <code>Rack::Session</code> expects <code>#get_session</code> to accept four arguments and requires <code>#destroy_session</code> instead of simply <code>#destroy</code>.</p></li>
466
+ <li><p>Template lookup now searches further up in the inheritance chain.</p></li>
467
+ </ul>
468
+ <h4 id="action-view">5.3 Action View</h4>
469
+ <ul>
470
+ <li><p>Added an <code>:authenticity_token</code> option to <code>form_tag</code> for custom handling or to omit the token by passing <code>:authenticity_token =&gt; false</code>.</p></li>
471
+ <li><p>Created <code>ActionView::Renderer</code> and specified an API for <code>ActionView::Context</code>.</p></li>
472
+ <li><p>In place <code>SafeBuffer</code> mutation is prohibited in Rails 3.1.</p></li>
473
+ <li><p>Added HTML5 <code>button_tag</code> helper.</p></li>
474
+ <li><p><code>file_field</code> automatically adds <code>:multipart =&gt; true</code> to the enclosing form.</p></li>
475
+ <li>
476
+ <p>Added a convenience idiom to generate HTML5 data-* attributes in tag helpers from a <code>:data</code> hash of options:</p>
477
+ <div class="code_container">
478
+ <pre class="brush: ruby; gutter: false; toolbar: false">
479
+ tag("div", :data =&gt; {:name =&gt; 'Stephen', :city_state =&gt; %w(Chicago IL)})
480
+ # =&gt; &lt;div data-name="Stephen" data-city-state="[&amp;quot;Chicago&amp;quot;,&amp;quot;IL&amp;quot;]" /&gt;
481
+
482
+ </pre>
483
+ </div>
484
+ </li>
485
+ </ul>
486
+ <p>Keys are dasherized. Values are JSON-encoded, except for strings and symbols.</p>
487
+ <ul>
488
+ <li><p><code>csrf_meta_tag</code> is renamed to <code>csrf_meta_tags</code> and aliases <code>csrf_meta_tag</code> for backwards compatibility.</p></li>
489
+ <li><p>The old template handler API is deprecated and the new API simply requires a template handler to respond to call.</p></li>
490
+ <li><p>rhtml and rxml are finally removed as template handlers.</p></li>
491
+ <li><p><code>config.action_view.cache_template_loading</code> is brought back which allows to decide whether templates should be cached or not.</p></li>
492
+ <li><p>The submit form helper does not generate an id "object_name_id" anymore.</p></li>
493
+ <li><p>Allows <code>FormHelper#form_for</code> to specify the <code>:method</code> as a direct option instead of through the <code>:html</code> hash. <code>form_for(@post, remote: true, method: :delete)</code> instead of <code>form_for(@post, remote: true, html: { method: :delete })</code>.</p></li>
494
+ <li><p>Provided <code>JavaScriptHelper#j()</code> as an alias for <code>JavaScriptHelper#escape_javascript()</code>. This supersedes the <code>Object#j()</code> method that the JSON gem adds within templates using the JavaScriptHelper.</p></li>
495
+ <li><p>Allows AM/PM format in datetime selectors.</p></li>
496
+ <li><p><code>auto_link</code> has been removed from Rails and extracted into the <a href="https://github.com/tenderlove/rails_autolink">rails_autolink gem</a></p></li>
497
+ </ul>
498
+ <h3 id="active-record">6 Active Record</h3>
499
+ <ul>
500
+ <li>
501
+ <p>Added a class method <code>pluralize_table_names</code> to singularize/pluralize table names of individual models. Previously this could only be set globally for all models through <code>ActiveRecord::Base.pluralize_table_names</code>.</p>
502
+ <div class="code_container">
503
+ <pre class="brush: ruby; gutter: false; toolbar: false">
504
+ class User &lt; ActiveRecord::Base
505
+ self.pluralize_table_names = false
506
+ end
507
+
508
+ </pre>
509
+ </div>
510
+ </li>
511
+ <li>
512
+ <p>Added block setting of attributes to singular associations. The block will get called after the instance is initialized.</p>
513
+ <div class="code_container">
514
+ <pre class="brush: ruby; gutter: false; toolbar: false">
515
+ class User &lt; ActiveRecord::Base
516
+ has_one :account
517
+ end
518
+
519
+ user.build_account{ |a| a.credit_limit = 100.0 }
520
+
521
+ </pre>
522
+ </div>
523
+ </li>
524
+ <li><p>Added <code>ActiveRecord::Base.attribute_names</code> to return a list of attribute names. This will return an empty array if the model is abstract or the table does not exist.</p></li>
525
+ <li><p>CSV Fixtures are deprecated and support will be removed in Rails 3.2.0.</p></li>
526
+ <li>
527
+ <p><code>ActiveRecord#new</code>, <code>ActiveRecord#create</code> and <code>ActiveRecord#update_attributes</code> all accept a second hash as an option that allows you to specify which role to consider when assigning attributes. This is built on top of Active Model's new mass assignment capabilities:</p>
528
+ <div class="code_container">
529
+ <pre class="brush: ruby; gutter: false; toolbar: false">
530
+ class Post &lt; ActiveRecord::Base
531
+ attr_accessible :title
532
+ attr_accessible :title, :published_at, :as =&gt; :admin
533
+ end
534
+
535
+ Post.new(params[:post], :as =&gt; :admin)
536
+
537
+ </pre>
538
+ </div>
539
+ </li>
540
+ <li><p><code>default_scope</code> can now take a block, lambda, or any other object which responds to call for lazy evaluation.</p></li>
541
+ <li><p>Default scopes are now evaluated at the latest possible moment, to avoid problems where scopes would be created which would implicitly contain the default scope, which would then be impossible to get rid of via Model.unscoped.</p></li>
542
+ <li><p>PostgreSQL adapter only supports PostgreSQL version 8.2 and higher.</p></li>
543
+ <li><p><code>ConnectionManagement</code> middleware is changed to clean up the connection pool after the rack body has been flushed.</p></li>
544
+ <li><p>Added an <code>update_column</code> method on Active Record. This new method updates a given attribute on an object, skipping validations and callbacks. It is recommended to use <code>update_attributes</code> or <code>update_attribute</code> unless you are sure you do not want to execute any callback, including the modification of the <code>updated_at</code> column. It should not be called on new records.</p></li>
545
+ <li><p>Associations with a <code>:through</code> option can now use any association as the through or source association, including other associations which have a <code>:through</code> option and <code>has_and_belongs_to_many</code> associations.</p></li>
546
+ <li><p>The configuration for the current database connection is now accessible via <code>ActiveRecord::Base.connection_config</code>.</p></li>
547
+ <li>
548
+ <p>limits and offsets are removed from COUNT queries unless both are supplied.</p>
549
+ <div class="code_container">
550
+ <pre class="brush: ruby; gutter: false; toolbar: false">
551
+ People.limit(1).count # =&gt; 'SELECT COUNT(*) FROM people'
552
+ People.offset(1).count # =&gt; 'SELECT COUNT(*) FROM people'
553
+ People.limit(1).offset(1).count # =&gt; 'SELECT COUNT(*) FROM people LIMIT 1 OFFSET 1'
554
+
555
+ </pre>
556
+ </div>
557
+ </li>
558
+ <li><p><code>ActiveRecord::Associations::AssociationProxy</code> has been split. There is now an <code>Association</code> class (and subclasses) which are responsible for operating on associations, and then a separate, thin wrapper called <code>CollectionProxy</code>, which proxies collection associations. This prevents namespace pollution, separates concerns, and will allow further refactorings.</p></li>
559
+ <li><p>Singular associations (<code>has_one</code>, <code>belongs_to</code>) no longer have a proxy and simply returns the associated record or <code>nil</code>. This means that you should not use undocumented methods such as <code>bob.mother.create</code> - use <code>bob.create_mother</code> instead.</p></li>
560
+ <li><p>Support the <code>:dependent</code> option on <code>has_many :through</code> associations. For historical and practical reasons, <code>:delete_all</code> is the default deletion strategy employed by <code>association.delete(*records)</code>, despite the fact that the default strategy is <code>:nullify</code> for regular has_many. Also, this only works at all if the source reflection is a belongs_to. For other situations, you should directly modify the through association.</p></li>
561
+ <li><p>The behavior of <code>association.destroy</code> for <code>has_and_belongs_to_many</code> and <code>has_many :through</code> is changed. From now on, 'destroy' or 'delete' on an association will be taken to mean 'get rid of the link', not (necessarily) 'get rid of the associated records'.</p></li>
562
+ <li><p>Previously, <code>has_and_belongs_to_many.destroy(*records)</code> would destroy the records themselves. It would not delete any records in the join table. Now, it deletes the records in the join table.</p></li>
563
+ <li><p>Previously, <code>has_many_through.destroy(*records)</code> would destroy the records themselves, and the records in the join table. [Note: This has not always been the case; previous version of Rails only deleted the records themselves.] Now, it destroys only the records in the join table.</p></li>
564
+ <li><p>Note that this change is backwards-incompatible to an extent, but there is unfortunately no way to 'deprecate' it before changing it. The change is being made in order to have consistency as to the meaning of 'destroy' or 'delete' across the different types of associations. If you wish to destroy the records themselves, you can do <code>records.association.each(&amp;:destroy)</code>.</p></li>
565
+ <li>
566
+ <p>Add <code>:bulk =&gt; true</code> option to <code>change_table</code> to make all the schema changes defined in a block using a single ALTER statement.</p>
567
+ <div class="code_container">
568
+ <pre class="brush: ruby; gutter: false; toolbar: false">
569
+ change_table(:users, :bulk =&gt; true) do |t|
570
+ t.string :company_name
571
+ t.change :birthdate, :datetime
572
+ end
573
+
574
+ </pre>
575
+ </div>
576
+ </li>
577
+ <li><p>Removed support for accessing attributes on a <code>has_and_belongs_to_many</code> join table. <code>has_many :through</code> needs to be used.</p></li>
578
+ <li><p>Added a <code>create_association!</code> method for <code>has_one</code> and <code>belongs_to</code> associations.</p></li>
579
+ <li>
580
+ <p>Migrations are now reversible, meaning that Rails will figure out how to reverse your migrations. To use reversible migrations, just define the <code>change</code> method.</p>
581
+ <div class="code_container">
582
+ <pre class="brush: ruby; gutter: false; toolbar: false">
583
+ class MyMigration &lt; ActiveRecord::Migration
584
+ def change
585
+ create_table(:horses) do |t|
586
+ t.column :content, :text
587
+ t.column :remind_at, :datetime
588
+ end
589
+ end
590
+ end
591
+
592
+ </pre>
593
+ </div>
594
+ </li>
595
+ <li><p>Some things cannot be automatically reversed for you. If you know how to reverse those things, you should define <code>up</code> and <code>down</code> in your migration. If you define something in change that cannot be reversed, an <code>IrreversibleMigration</code> exception will be raised when going down.</p></li>
596
+ <li>
597
+ <p>Migrations now use instance methods rather than class methods:</p>
598
+ <div class="code_container">
599
+ <pre class="brush: ruby; gutter: false; toolbar: false">
600
+ class FooMigration &lt; ActiveRecord::Migration
601
+ def up # Not self.up
602
+ ...
603
+ end
604
+ end
605
+
606
+ </pre>
607
+ </div>
608
+ </li>
609
+ <li><p>Migration files generated from model and constructive migration generators (for example, add_name_to_users) use the reversible migration's <code>change</code> method instead of the ordinary <code>up</code> and <code>down</code> methods.</p></li>
610
+ <li>
611
+ <p>Removed support for interpolating string SQL conditions on associations. Instead, a proc should be used.</p>
612
+ <div class="code_container">
613
+ <pre class="brush: ruby; gutter: false; toolbar: false">
614
+ has_many :things, :conditions =&gt; 'foo = #{bar}' # before
615
+ has_many :things, :conditions =&gt; proc { "foo = #{bar}" } # after
616
+
617
+ </pre>
618
+ </div>
619
+ <p>Inside the proc, <code>self</code> is the object which is the owner of the association, unless you are eager loading the association, in which case <code>self</code> is the class which the association is within.</p>
620
+ <p>You can have any "normal" conditions inside the proc, so the following will work too:</p>
621
+ <div class="code_container">
622
+ <pre class="brush: ruby; gutter: false; toolbar: false">
623
+ has_many :things, :conditions =&gt; proc { ["foo = ?", bar] }
624
+
625
+ </pre>
626
+ </div>
627
+ </li>
628
+ <li><p>Previously <code>:insert_sql</code> and <code>:delete_sql</code> on <code>has_and_belongs_to_many</code> association allowed you to call 'record' to get the record being inserted or deleted. This is now passed as an argument to the proc.</p></li>
629
+ <li>
630
+ <p>Added <code>ActiveRecord::Base#has_secure_password</code> (via <code>ActiveModel::SecurePassword</code>) to encapsulate dead-simple password usage with BCrypt encryption and salting.</p>
631
+ <div class="code_container">
632
+ <pre class="brush: ruby; gutter: false; toolbar: false">
633
+ # Schema: User(name:string, password_digest:string, password_salt:string)
634
+ class User &lt; ActiveRecord::Base
635
+ has_secure_password
636
+ end
637
+
638
+ </pre>
639
+ </div>
640
+ </li>
641
+ <li><p>When a model is generated <code>add_index</code> is added by default for <code>belongs_to</code> or <code>references</code> columns.</p></li>
642
+ <li><p>Setting the id of a <code>belongs_to</code> object will update the reference to the object.</p></li>
643
+ <li><p><code>ActiveRecord::Base#dup</code> and <code>ActiveRecord::Base#clone</code> semantics have changed to closer match normal Ruby dup and clone semantics.</p></li>
644
+ <li><p>Calling <code>ActiveRecord::Base#clone</code> will result in a shallow copy of the record, including copying the frozen state. No callbacks will be called.</p></li>
645
+ <li><p>Calling <code>ActiveRecord::Base#dup</code> will duplicate the record, including calling after initialize hooks. Frozen state will not be copied, and all associations will be cleared. A duped record will return <code>true</code> for <code>new_record?</code>, have a <code>nil</code> id field, and is saveable.</p></li>
646
+ <li><p>The query cache now works with prepared statements. No changes in the applications are required.</p></li>
647
+ </ul>
648
+ <h3 id="active-model">7 Active Model</h3>
649
+ <ul>
650
+ <li><p><code>attr_accessible</code> accepts an option <code>:as</code> to specify a role.</p></li>
651
+ <li><p><code>InclusionValidator</code>, <code>ExclusionValidator</code>, and <code>FormatValidator</code> now accepts an option which can be a proc, a lambda, or anything that respond to <code>call</code>. This option will be called with the current record as an argument and returns an object which respond to <code>include?</code> for <code>InclusionValidator</code> and <code>ExclusionValidator</code>, and returns a regular expression object for <code>FormatValidator</code>.</p></li>
652
+ <li><p>Added <code>ActiveModel::SecurePassword</code> to encapsulate dead-simple password usage with BCrypt encryption and salting.</p></li>
653
+ <li><p><code>ActiveModel::AttributeMethods</code> allows attributes to be defined on demand.</p></li>
654
+ <li><p>Added support for selectively enabling and disabling observers.</p></li>
655
+ <li><p>Alternate <code>I18n</code> namespace lookup is no longer supported.</p></li>
656
+ </ul>
657
+ <h3 id="active-resource">8 Active Resource</h3>
658
+ <ul>
659
+ <li>
660
+ <p>The default format has been changed to JSON for all requests. If you want to continue to use XML you will need to set <code>self.format = :xml</code> in the class. For example,</p>
661
+ <div class="code_container">
662
+ <pre class="brush: ruby; gutter: false; toolbar: false">
663
+ class User &lt; ActiveResource::Base
664
+ self.format = :xml
665
+ end
666
+
667
+ </pre>
668
+ </div>
669
+ </li>
670
+ </ul>
671
+ <h3 id="active-support">9 Active Support</h3>
672
+ <ul>
673
+ <li><p><code>ActiveSupport::Dependencies</code> now raises <code>NameError</code> if it finds an existing constant in <code>load_missing_constant</code>.</p></li>
674
+ <li><p>Added a new reporting method <code>Kernel#quietly</code> which silences both <code>STDOUT</code> and <code>STDERR</code>.</p></li>
675
+ <li><p>Added <code>String#inquiry</code> as a convenience method for turning a String into a <code>StringInquirer</code> object.</p></li>
676
+ <li><p>Added <code>Object#in?</code> to test if an object is included in another object.</p></li>
677
+ <li><p><code>LocalCache</code> strategy is now a real middleware class and no longer an anonymous class.</p></li>
678
+ <li><p><code>ActiveSupport::Dependencies::ClassCache</code> class has been introduced for holding references to reloadable classes.</p></li>
679
+ <li><p><code>ActiveSupport::Dependencies::Reference</code> has been refactored to take direct advantage of the new <code>ClassCache</code>.</p></li>
680
+ <li><p>Backports <code>Range#cover?</code> as an alias for <code>Range#include?</code> in Ruby 1.8.</p></li>
681
+ <li><p>Added <code>weeks_ago</code> and <code>prev_week</code> to Date/DateTime/Time.</p></li>
682
+ <li><p>Added <code>before_remove_const</code> callback to <code>ActiveSupport::Dependencies.remove_unloadable_constants!</code>.</p></li>
683
+ </ul>
684
+ <p>Deprecations:</p>
685
+ <ul>
686
+ <li>
687
+ <code>ActiveSupport::SecureRandom</code> is deprecated in favor of <code>SecureRandom</code> from the Ruby standard library.</li>
688
+ </ul>
689
+ <h3 id="credits">10 Credits</h3><p>See the <a href="http://contributors.rubyonrails.org/">full list of contributors to Rails</a> for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.</p><p>Rails 3.1 Release Notes were compiled by <a href="https://github.com/vijaydev.">Vijay Dev</a></p>
690
+
691
+ <h3>Feedback</h3>
692
+ <p>
693
+ You're encouraged to help improve the quality of this guide.
694
+ </p>
695
+ <p>
696
+ Please contribute if you see any typos or factual errors.
697
+ 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.
698
+ </p>
699
+ <p>
700
+ You may also find incomplete content, or stuff that is not up to date.
701
+ Please do add any missing documentation for master. Make sure to check
702
+ <a href="http://edgeguides.rubyonrails.org">Edge Guides</a> first to verify
703
+ if the issues are already fixed or not on the master branch.
704
+ Check the <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
705
+ for style and conventions.
706
+ </p>
707
+ <p>
708
+ If for whatever reason you spot something to fix but cannot patch it yourself, please
709
+ <a href="https://github.com/rails/rails/issues">open an issue</a>.
710
+ </p>
711
+ <p>And last but not least, any kind of discussion regarding Ruby on Rails
712
+ documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
713
+ </p>
714
+ </div>
715
+ </div>
716
+ </div>
717
+
718
+ <hr class="hide" />
719
+ <div id="footer">
720
+ <div class="wrapper">
721
+ <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>
722
+ <p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
723
+
724
+ </div>
725
+ </div>
726
+
727
+ <script type="text/javascript" src="javascripts/jquery.min.js"></script>
728
+ <script type="text/javascript" src="javascripts/responsive-tables.js"></script>
729
+ <script type="text/javascript" src="javascripts/guides.js"></script>
730
+ <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
731
+ <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
732
+ <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
733
+ <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
734
+ <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
735
+ <script type="text/javascript">
736
+ SyntaxHighlighter.all();
737
+ $(guidesIndex.bind);
738
+ </script>
739
+ </body>
740
+ </html>