rails 4.1.14.2 → 5.2.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +33 -19
  3. metadata +65 -313
  4. data/guides/CHANGELOG.md +0 -106
  5. data/guides/Rakefile +0 -77
  6. data/guides/assets/images/akshaysurve.jpg +0 -0
  7. data/guides/assets/images/belongs_to.png +0 -0
  8. data/guides/assets/images/book_icon.gif +0 -0
  9. data/guides/assets/images/bullet.gif +0 -0
  10. data/guides/assets/images/chapters_icon.gif +0 -0
  11. data/guides/assets/images/check_bullet.gif +0 -0
  12. data/guides/assets/images/credits_pic_blank.gif +0 -0
  13. data/guides/assets/images/csrf.png +0 -0
  14. data/guides/assets/images/edge_badge.png +0 -0
  15. data/guides/assets/images/favicon.ico +0 -0
  16. data/guides/assets/images/feature_tile.gif +0 -0
  17. data/guides/assets/images/footer_tile.gif +0 -0
  18. data/guides/assets/images/fxn.png +0 -0
  19. data/guides/assets/images/getting_started/article_with_comments.png +0 -0
  20. data/guides/assets/images/getting_started/challenge.png +0 -0
  21. data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
  22. data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  23. data/guides/assets/images/getting_started/form_with_errors.png +0 -0
  24. data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
  25. data/guides/assets/images/getting_started/new_article.png +0 -0
  26. data/guides/assets/images/getting_started/rails_welcome.png +0 -0
  27. data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
  28. data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
  29. data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
  30. data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
  31. data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
  32. data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
  33. data/guides/assets/images/grey_bullet.gif +0 -0
  34. data/guides/assets/images/habtm.png +0 -0
  35. data/guides/assets/images/has_many.png +0 -0
  36. data/guides/assets/images/has_many_through.png +0 -0
  37. data/guides/assets/images/has_one.png +0 -0
  38. data/guides/assets/images/has_one_through.png +0 -0
  39. data/guides/assets/images/header_backdrop.png +0 -0
  40. data/guides/assets/images/header_tile.gif +0 -0
  41. data/guides/assets/images/i18n/demo_html_safe.png +0 -0
  42. data/guides/assets/images/i18n/demo_localized_pirate.png +0 -0
  43. data/guides/assets/images/i18n/demo_translated_en.png +0 -0
  44. data/guides/assets/images/i18n/demo_translated_pirate.png +0 -0
  45. data/guides/assets/images/i18n/demo_translation_missing.png +0 -0
  46. data/guides/assets/images/i18n/demo_untranslated.png +0 -0
  47. data/guides/assets/images/icons/README +0 -5
  48. data/guides/assets/images/icons/callouts/1.png +0 -0
  49. data/guides/assets/images/icons/callouts/10.png +0 -0
  50. data/guides/assets/images/icons/callouts/11.png +0 -0
  51. data/guides/assets/images/icons/callouts/12.png +0 -0
  52. data/guides/assets/images/icons/callouts/13.png +0 -0
  53. data/guides/assets/images/icons/callouts/14.png +0 -0
  54. data/guides/assets/images/icons/callouts/15.png +0 -0
  55. data/guides/assets/images/icons/callouts/2.png +0 -0
  56. data/guides/assets/images/icons/callouts/3.png +0 -0
  57. data/guides/assets/images/icons/callouts/4.png +0 -0
  58. data/guides/assets/images/icons/callouts/5.png +0 -0
  59. data/guides/assets/images/icons/callouts/6.png +0 -0
  60. data/guides/assets/images/icons/callouts/7.png +0 -0
  61. data/guides/assets/images/icons/callouts/8.png +0 -0
  62. data/guides/assets/images/icons/callouts/9.png +0 -0
  63. data/guides/assets/images/icons/caution.png +0 -0
  64. data/guides/assets/images/icons/example.png +0 -0
  65. data/guides/assets/images/icons/home.png +0 -0
  66. data/guides/assets/images/icons/important.png +0 -0
  67. data/guides/assets/images/icons/next.png +0 -0
  68. data/guides/assets/images/icons/note.png +0 -0
  69. data/guides/assets/images/icons/prev.png +0 -0
  70. data/guides/assets/images/icons/tip.png +0 -0
  71. data/guides/assets/images/icons/up.png +0 -0
  72. data/guides/assets/images/icons/warning.png +0 -0
  73. data/guides/assets/images/nav_arrow.gif +0 -0
  74. data/guides/assets/images/oscardelben.jpg +0 -0
  75. data/guides/assets/images/polymorphic.png +0 -0
  76. data/guides/assets/images/radar.png +0 -0
  77. data/guides/assets/images/rails4_features.png +0 -0
  78. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  79. data/guides/assets/images/rails_guides_logo.gif +0 -0
  80. data/guides/assets/images/rails_logo_remix.gif +0 -0
  81. data/guides/assets/images/session_fixation.png +0 -0
  82. data/guides/assets/images/tab_grey.gif +0 -0
  83. data/guides/assets/images/tab_info.gif +0 -0
  84. data/guides/assets/images/tab_note.gif +0 -0
  85. data/guides/assets/images/tab_red.gif +0 -0
  86. data/guides/assets/images/tab_yellow.gif +0 -0
  87. data/guides/assets/images/tab_yellow.png +0 -0
  88. data/guides/assets/images/vijaydev.jpg +0 -0
  89. data/guides/assets/javascripts/guides.js +0 -53
  90. data/guides/assets/javascripts/jquery.min.js +0 -4
  91. data/guides/assets/javascripts/responsive-tables.js +0 -43
  92. data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  93. data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  94. data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  95. data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  96. data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  97. data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  98. data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  99. data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  100. data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  101. data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  102. data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  103. data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  104. data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  105. data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  106. data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  107. data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  108. data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  109. data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  110. data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  111. data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  112. data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  113. data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  114. data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  115. data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  116. data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  117. data/guides/assets/javascripts/syntaxhighlighter/shCore.js +0 -17
  118. data/guides/assets/stylesheets/fixes.css +0 -16
  119. data/guides/assets/stylesheets/kindle.css +0 -11
  120. data/guides/assets/stylesheets/main.css +0 -710
  121. data/guides/assets/stylesheets/print.css +0 -52
  122. data/guides/assets/stylesheets/reset.css +0 -43
  123. data/guides/assets/stylesheets/responsive-tables.css +0 -50
  124. data/guides/assets/stylesheets/style.css +0 -13
  125. data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +0 -226
  126. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  127. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  128. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  129. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  130. data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  131. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  132. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  133. data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  134. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  135. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  136. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  137. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  138. data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  139. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  140. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  141. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  142. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  143. data/guides/bug_report_templates/action_controller_gem.rb +0 -47
  144. data/guides/bug_report_templates/action_controller_master.rb +0 -53
  145. data/guides/bug_report_templates/active_record_gem.rb +0 -40
  146. data/guides/bug_report_templates/active_record_master.rb +0 -49
  147. data/guides/bug_report_templates/generic_gem.rb +0 -15
  148. data/guides/bug_report_templates/generic_master.rb +0 -26
  149. data/guides/code/getting_started/Gemfile +0 -40
  150. data/guides/code/getting_started/Gemfile.lock +0 -125
  151. data/guides/code/getting_started/README.rdoc +0 -28
  152. data/guides/code/getting_started/Rakefile +0 -6
  153. data/guides/code/getting_started/app/assets/javascripts/application.js +0 -15
  154. data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +0 -3
  155. data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +0 -3
  156. data/guides/code/getting_started/app/assets/javascripts/welcome.js.coffee +0 -3
  157. data/guides/code/getting_started/app/assets/stylesheets/application.css +0 -13
  158. data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +0 -3
  159. data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +0 -3
  160. data/guides/code/getting_started/app/assets/stylesheets/welcome.css.scss +0 -3
  161. data/guides/code/getting_started/app/controllers/application_controller.rb +0 -5
  162. data/guides/code/getting_started/app/controllers/comments_controller.rb +0 -23
  163. data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -53
  164. data/guides/code/getting_started/app/controllers/welcome_controller.rb +0 -4
  165. data/guides/code/getting_started/app/helpers/application_helper.rb +0 -2
  166. data/guides/code/getting_started/app/helpers/comments_helper.rb +0 -2
  167. data/guides/code/getting_started/app/helpers/posts_helper.rb +0 -2
  168. data/guides/code/getting_started/app/helpers/welcome_helper.rb +0 -2
  169. data/guides/code/getting_started/app/models/comment.rb +0 -3
  170. data/guides/code/getting_started/app/models/post.rb +0 -7
  171. data/guides/code/getting_started/app/views/comments/_comment.html.erb +0 -15
  172. data/guides/code/getting_started/app/views/comments/_form.html.erb +0 -13
  173. data/guides/code/getting_started/app/views/layouts/application.html.erb +0 -14
  174. data/guides/code/getting_started/app/views/posts/_form.html.erb +0 -27
  175. data/guides/code/getting_started/app/views/posts/edit.html.erb +0 -5
  176. data/guides/code/getting_started/app/views/posts/index.html.erb +0 -21
  177. data/guides/code/getting_started/app/views/posts/new.html.erb +0 -5
  178. data/guides/code/getting_started/app/views/posts/show.html.erb +0 -18
  179. data/guides/code/getting_started/app/views/welcome/index.html.erb +0 -4
  180. data/guides/code/getting_started/bin/bundle +0 -4
  181. data/guides/code/getting_started/bin/rails +0 -4
  182. data/guides/code/getting_started/bin/rake +0 -4
  183. data/guides/code/getting_started/config.ru +0 -4
  184. data/guides/code/getting_started/config/application.rb +0 -18
  185. data/guides/code/getting_started/config/boot.rb +0 -4
  186. data/guides/code/getting_started/config/database.yml +0 -25
  187. data/guides/code/getting_started/config/environment.rb +0 -5
  188. data/guides/code/getting_started/config/environments/development.rb +0 -30
  189. data/guides/code/getting_started/config/environments/production.rb +0 -80
  190. data/guides/code/getting_started/config/environments/test.rb +0 -36
  191. data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +0 -7
  192. data/guides/code/getting_started/config/initializers/filter_parameter_logging.rb +0 -4
  193. data/guides/code/getting_started/config/initializers/inflections.rb +0 -16
  194. data/guides/code/getting_started/config/initializers/locale.rb +0 -9
  195. data/guides/code/getting_started/config/initializers/mime_types.rb +0 -5
  196. data/guides/code/getting_started/config/initializers/secret_token.rb +0 -12
  197. data/guides/code/getting_started/config/initializers/session_store.rb +0 -3
  198. data/guides/code/getting_started/config/initializers/wrap_parameters.rb +0 -14
  199. data/guides/code/getting_started/config/locales/en.yml +0 -23
  200. data/guides/code/getting_started/config/routes.rb +0 -7
  201. data/guides/code/getting_started/db/migrate/20130122042648_create_posts.rb +0 -10
  202. data/guides/code/getting_started/db/migrate/20130122045842_create_comments.rb +0 -11
  203. data/guides/code/getting_started/db/schema.rb +0 -33
  204. data/guides/code/getting_started/db/seeds.rb +0 -7
  205. data/guides/code/getting_started/public/404.html +0 -60
  206. data/guides/code/getting_started/public/422.html +0 -60
  207. data/guides/code/getting_started/public/500.html +0 -59
  208. data/guides/code/getting_started/public/favicon.ico +0 -0
  209. data/guides/code/getting_started/public/robots.txt +0 -5
  210. data/guides/code/getting_started/test/controllers/comments_controller_test.rb +0 -7
  211. data/guides/code/getting_started/test/controllers/posts_controller_test.rb +0 -7
  212. data/guides/code/getting_started/test/controllers/welcome_controller_test.rb +0 -9
  213. data/guides/code/getting_started/test/fixtures/comments.yml +0 -11
  214. data/guides/code/getting_started/test/fixtures/posts.yml +0 -9
  215. data/guides/code/getting_started/test/helpers/comments_helper_test.rb +0 -4
  216. data/guides/code/getting_started/test/helpers/posts_helper_test.rb +0 -4
  217. data/guides/code/getting_started/test/helpers/welcome_helper_test.rb +0 -4
  218. data/guides/code/getting_started/test/models/comment_test.rb +0 -7
  219. data/guides/code/getting_started/test/models/post_test.rb +0 -7
  220. data/guides/code/getting_started/test/test_helper.rb +0 -12
  221. data/guides/rails_guides.rb +0 -63
  222. data/guides/rails_guides/generator.rb +0 -248
  223. data/guides/rails_guides/helpers.rb +0 -53
  224. data/guides/rails_guides/indexer.rb +0 -68
  225. data/guides/rails_guides/kindle.rb +0 -119
  226. data/guides/rails_guides/levenshtein.rb +0 -31
  227. data/guides/rails_guides/markdown.rb +0 -163
  228. data/guides/rails_guides/markdown/renderer.rb +0 -82
  229. data/guides/source/2_2_release_notes.md +0 -435
  230. data/guides/source/2_3_release_notes.md +0 -621
  231. data/guides/source/3_0_release_notes.md +0 -611
  232. data/guides/source/3_1_release_notes.md +0 -556
  233. data/guides/source/3_2_release_notes.md +0 -565
  234. data/guides/source/4_0_release_notes.md +0 -276
  235. data/guides/source/4_1_release_notes.md +0 -731
  236. data/guides/source/_license.html.erb +0 -2
  237. data/guides/source/_welcome.html.erb +0 -25
  238. data/guides/source/action_controller_overview.md +0 -1175
  239. data/guides/source/action_mailer_basics.md +0 -689
  240. data/guides/source/action_view_overview.md +0 -1602
  241. data/guides/source/active_model_basics.md +0 -200
  242. data/guides/source/active_record_basics.md +0 -373
  243. data/guides/source/active_record_callbacks.md +0 -410
  244. data/guides/source/active_record_querying.md +0 -1785
  245. data/guides/source/active_record_validations.md +0 -1169
  246. data/guides/source/active_support_core_extensions.md +0 -3817
  247. data/guides/source/active_support_instrumentation.md +0 -496
  248. data/guides/source/api_documentation_guidelines.md +0 -315
  249. data/guides/source/asset_pipeline.md +0 -1165
  250. data/guides/source/association_basics.md +0 -2229
  251. data/guides/source/caching_with_rails.md +0 -354
  252. data/guides/source/command_line.md +0 -603
  253. data/guides/source/configuring.md +0 -942
  254. data/guides/source/contributing_to_ruby_on_rails.md +0 -544
  255. data/guides/source/credits.html.erb +0 -80
  256. data/guides/source/debugging_rails_applications.md +0 -707
  257. data/guides/source/development_dependencies_install.md +0 -278
  258. data/guides/source/documents.yaml +0 -193
  259. data/guides/source/engines.md +0 -1412
  260. data/guides/source/form_helpers.md +0 -1001
  261. data/guides/source/generators.md +0 -663
  262. data/guides/source/getting_started.md +0 -1946
  263. data/guides/source/i18n.md +0 -1043
  264. data/guides/source/index.html.erb +0 -27
  265. data/guides/source/initialization.md +0 -657
  266. data/guides/source/kindle/copyright.html.erb +0 -1
  267. data/guides/source/kindle/layout.html.erb +0 -27
  268. data/guides/source/kindle/rails_guides.opf.erb +0 -52
  269. data/guides/source/kindle/toc.html.erb +0 -24
  270. data/guides/source/kindle/toc.ncx.erb +0 -64
  271. data/guides/source/kindle/welcome.html.erb +0 -5
  272. data/guides/source/layout.html.erb +0 -146
  273. data/guides/source/layouts_and_rendering.md +0 -1226
  274. data/guides/source/maintenance_policy.md +0 -75
  275. data/guides/source/migrations.md +0 -1143
  276. data/guides/source/nested_model_forms.md +0 -225
  277. data/guides/source/plugins.md +0 -444
  278. data/guides/source/rails_application_templates.md +0 -248
  279. data/guides/source/rails_on_rack.md +0 -332
  280. data/guides/source/routing.md +0 -1115
  281. data/guides/source/ruby_on_rails_guides_guidelines.md +0 -128
  282. data/guides/source/security.md +0 -1018
  283. data/guides/source/testing.md +0 -1052
  284. data/guides/source/upgrading_ruby_on_rails.md +0 -928
  285. data/guides/source/working_with_javascript_in_rails.md +0 -405
  286. data/guides/w3c_validator.rb +0 -95
@@ -1,928 +0,0 @@
1
- A Guide for Upgrading Ruby on Rails
2
- ===================================
3
-
4
- This guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails. These steps are also available in individual release guides.
5
-
6
- --------------------------------------------------------------------------------
7
-
8
- General Advice
9
- --------------
10
-
11
- Before attempting to upgrade an existing application, you should be sure you have a good reason to upgrade. You need to balance out several factors: the need for new features, the increasing difficulty of finding support for old code, and your available time and skills, to name a few.
12
-
13
- ### Test Coverage
14
-
15
- The best way to be sure that your application still works after upgrading is to have good test coverage before you start the process. If you don't have automated tests that exercise the bulk of your application, you'll need to spend time manually exercising all the parts that have changed. In the case of a Rails upgrade, that will mean every single piece of functionality in the application. Do yourself a favor and make sure your test coverage is good _before_ you start an upgrade.
16
-
17
- ### Ruby Versions
18
-
19
- Rails generally stays close to the latest released Ruby version when it's released:
20
-
21
- * Rails 3 and above require Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially. You should upgrade as early as possible.
22
- * Rails 3.2.x is the last branch to support Ruby 1.8.7.
23
- * Rails 4 prefers Ruby 2.0 and requires 1.9.3 or newer.
24
-
25
- TIP: Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails. Ruby Enterprise Edition has these fixed since the release of 1.8.7-2010.02. 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 straight to 1.9.3 for smooth sailing.
26
-
27
- Upgrading from Rails 4.0 to Rails 4.1
28
- -------------------------------------
29
-
30
- ### CSRF protection from remote `<script>` tags
31
-
32
- Or, "whaaat my tests are failing!!!?"
33
-
34
- Cross-site request forgery (CSRF) protection now covers GET requests with
35
- JavaScript responses, too. That prevents a third-party site from referencing
36
- your JavaScript URL and attempting to run it to extract sensitive data.
37
-
38
- This means that your functional and integration tests that use
39
-
40
- ```ruby
41
- get :index, format: :js
42
- ```
43
-
44
- will now trigger CSRF protection. Switch to
45
-
46
- ```ruby
47
- xhr :get, :index, format: :js
48
- ```
49
-
50
- to explicitly test an XmlHttpRequest.
51
-
52
- If you really mean to load JavaScript from remote `<script>` tags, skip CSRF
53
- protection on that action.
54
-
55
- ### Spring
56
-
57
- If you want to use Spring as your application preloader you need to:
58
-
59
- 1. Add `gem 'spring', group: :development` to your `Gemfile`.
60
- 2. Install spring using `bundle install`.
61
- 3. Springify your binstubs with `bundle exec spring binstub --all`.
62
-
63
- NOTE: User defined rake tasks will run in the `development` environment by
64
- default. If you want them to run in other environments consult the
65
- [Spring README](https://github.com/rails/spring#rake).
66
-
67
- ### `config/secrets.yml`
68
-
69
- If you want to use the new `secrets.yml` convention to store your application's
70
- secrets, you need to:
71
-
72
- 1. Create a `secrets.yml` file in your `config` folder with the following content:
73
-
74
- ```yaml
75
- development:
76
- secret_key_base:
77
-
78
- test:
79
- secret_key_base:
80
-
81
- production:
82
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
83
- ```
84
-
85
- 2. Use your existing `secret_key_base` from the `secret_token.rb` initializer to
86
- set the SECRET_KEY_BASE environment variable for whichever users run the Rails
87
- app in production mode. Alternately, you can simply copy the existing
88
- `secret_key_base` from the `secret_token.rb` initializer to `secrets.yml`
89
- under the `production` section, replacing '<%= ENV["SECRET_KEY_BASE"] %>'.
90
-
91
- 3. Remove the `secret_token.rb` initializer.
92
-
93
- 4. Use `rake secret` to generate new keys for the `development` and `test` sections.
94
-
95
- 5. Restart your server.
96
-
97
- ### Changes to test helper
98
-
99
- If your test helper contains a call to
100
- `ActiveRecord::Migration.check_pending!` this can be removed. The check
101
- is now done automatically when you `require 'test_help'`, although
102
- leaving this line in your helper is not harmful in any way.
103
-
104
- ### Cookies serializer
105
-
106
- Applications created before Rails 4.1 uses `Marshal` to serialize cookie values into
107
- the signed and encrypted cookie jars. If you want to use the new `JSON`-based format
108
- in your application, you can add an initializer file with the following content:
109
-
110
- ```ruby
111
- Rails.application.config.action_dispatch.cookies_serializer = :hybrid
112
- ```
113
-
114
- This would transparently migrate your existing `Marshal`-serialized cookies into the
115
- new `JSON`-based format.
116
-
117
- When using the `:json` or `:hybrid` serializer, you should beware that not all
118
- Ruby objects can be serialized as JSON. For example, `Date` and `Time` objects
119
- will be serialized as strings, and `Hash`es will have their keys stringified.
120
-
121
- ```ruby
122
- class CookiesController < ApplicationController
123
- def set_cookie
124
- cookies.encrypted[:expiration_date] = Date.tomorrow # => Thu, 20 Mar 2014
125
- redirect_to action: 'read_cookie'
126
- end
127
-
128
- def read_cookie
129
- cookies.encrypted[:expiration_date] # => "2014-03-20"
130
- end
131
- end
132
- ```
133
-
134
- It's advisable that you only store simple data (strings and numbers) in cookies.
135
- If you have to store complex objects, you would need to handle the conversion
136
- manually when reading the values on subsequent requests.
137
-
138
- If you use the cookie session store, this would apply to the `session` and
139
- `flash` hash as well.
140
-
141
- ### Flash structure changes
142
-
143
- Flash message keys are
144
- [normalized to strings](https://github.com/rails/rails/commit/a668beffd64106a1e1fedb71cc25eaaa11baf0c1). They
145
- can still be accessed using either symbols or strings. Lopping through the flash
146
- will always yield string keys:
147
-
148
- ```ruby
149
- flash["string"] = "a string"
150
- flash[:symbol] = "a symbol"
151
-
152
- # Rails < 4.1
153
- flash.keys # => ["string", :symbol]
154
-
155
- # Rails >= 4.1
156
- flash.keys # => ["string", "symbol"]
157
- ```
158
-
159
- Make sure you are comparing Flash message keys against strings.
160
-
161
- ### Changes in JSON handling
162
-
163
- There are a few major changes related to JSON handling in Rails 4.1.
164
-
165
- #### MultiJSON removal
166
-
167
- MultiJSON has reached its [end-of-life](https://github.com/rails/rails/pull/10576)
168
- and has been removed from Rails.
169
-
170
- If your application currently depend on MultiJSON directly, you have a few options:
171
-
172
- 1. Add 'multi_json' to your Gemfile. Note that this might cease to work in the future
173
-
174
- 2. Migrate away from MultiJSON by using `obj.to_json`, and `JSON.parse(str)` instead.
175
-
176
- WARNING: Do not simply replace `MultiJson.dump` and `MultiJson.load` with
177
- `JSON.dump` and `JSON.load`. These JSON gem APIs are meant for serializing and
178
- deserializing arbitrary Ruby objects and are generally [unsafe](http://www.ruby-doc.org/stdlib-2.0.0/libdoc/json/rdoc/JSON.html#method-i-load).
179
-
180
- #### JSON gem compatibility
181
-
182
- Historically, Rails had some compatibility issues with the JSON gem. Using
183
- `JSON.generate` and `JSON.dump` inside a Rails application could produce
184
- unexpected errors.
185
-
186
- Rails 4.1 fixed these issues by isolating its own encoder from the JSON gem. The
187
- JSON gem APIs will function as normal, but they will not have access to any
188
- Rails-specific features. For example:
189
-
190
- ```ruby
191
- class FooBar
192
- def as_json(options = nil)
193
- { foo: 'bar' }
194
- end
195
- end
196
-
197
- >> FooBar.new.to_json # => "{\"foo\":\"bar\"}"
198
- >> JSON.generate(FooBar.new, quirks_mode: true) # => "\"#<FooBar:0x007fa80a481610>\""
199
- ```
200
-
201
- #### New JSON encoder
202
-
203
- The JSON encoder in Rails 4.1 has been rewritten to take advantage of the JSON
204
- gem. For most applications, this should be a transparent change. However, as
205
- part of the rewrite, the following features have been removed from the encoder:
206
-
207
- 1. Circular data structure detection
208
- 2. Support for the `encode_json` hook
209
- 3. Option to encode `BigDecimal` objects as numbers instead of strings
210
-
211
- If your application depends on one of these features, you can get them back by
212
- adding the [`activesupport-json_encoder`](https://github.com/rails/activesupport-json_encoder)
213
- gem to your Gemfile.
214
-
215
- #### JSON representation of Time objects
216
-
217
- `#as_json` for objects with time component (`Time`, `DateTime`, `ActiveSupport::TimeWithZone`)
218
- now returns millisecond precision by default. If you need to keep old behavior with no millisecond
219
- precision, set the following in an initializer:
220
-
221
- ```
222
- ActiveSupport::JSON::Encoding.time_precision = 0
223
- ```
224
-
225
- ### Usage of `return` within inline callback blocks
226
-
227
- Previously, Rails allowed inline callback blocks to use `return` this way:
228
-
229
- ```ruby
230
- class ReadOnlyModel < ActiveRecord::Base
231
- before_save { return false } # BAD
232
- end
233
- ```
234
-
235
- This behaviour was never intentionally supported. Due to a change in the internals
236
- of `ActiveSupport::Callbacks`, this is no longer allowed in Rails 4.1. Using a
237
- `return` statement in an inline callback block causes a `LocalJumpError` to
238
- be raised when the callback is executed.
239
-
240
- Inline callback blocks using `return` can be refactored to evaluate to the
241
- returned value:
242
-
243
- ```ruby
244
- class ReadOnlyModel < ActiveRecord::Base
245
- before_save { false } # GOOD
246
- end
247
- ```
248
-
249
- Alternatively, if `return` is preferred it is recommended to explicitly define
250
- a method:
251
-
252
- ```ruby
253
- class ReadOnlyModel < ActiveRecord::Base
254
- before_save :before_save_callback # GOOD
255
-
256
- private
257
- def before_save_callback
258
- return false
259
- end
260
- end
261
- ```
262
-
263
- This change applies to most places in Rails where callbacks are used, including
264
- Active Record and Active Model callbacks, as well as filters in Action
265
- Controller (e.g. `before_action`).
266
-
267
- See [this pull request](https://github.com/rails/rails/pull/13271) for more
268
- details.
269
-
270
- ### Methods defined in Active Record fixtures
271
-
272
- Rails 4.1 evaluates each fixture's ERB in a separate context, so helper methods
273
- defined in a fixture will not be available in other fixtures.
274
-
275
- Helper methods that are used in multiple fixtures should be defined on modules
276
- included in the newly introduced `ActiveRecord::FixtureSet.context_class`, in
277
- `test_helper.rb`.
278
-
279
- ```ruby
280
- module FixtureFileHelpers
281
- def file_sha(path)
282
- Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
283
- end
284
- end
285
- ActiveRecord::FixtureSet.context_class.send :include, FixtureFileHelpers
286
- ```
287
-
288
- ### I18n enforcing available locales
289
-
290
- Rails 4.1 now defaults the I18n option `enforce_available_locales` to `true`,
291
- meaning that it will make sure that all locales passed to it must be declared in
292
- the `available_locales` list.
293
-
294
- To disable it (and allow I18n to accept *any* locale option) add the following
295
- configuration to your application:
296
-
297
- ```ruby
298
- config.i18n.enforce_available_locales = false
299
- ```
300
-
301
- Note that this option was added as a security measure, to ensure user input could
302
- not be used as locale information unless previously known, so it's recommended not
303
- to disable this option unless you have a strong reason for doing so.
304
-
305
- ### Mutator methods called on Relation
306
-
307
- `Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
308
- to an `Array` by calling `#to_a` before using these methods.
309
-
310
- It intends to prevent odd bugs and confusion in code that call mutator
311
- methods directly on the `Relation`.
312
-
313
- ```ruby
314
- # Instead of this
315
- Author.where(name: 'Hank Moody').compact!
316
-
317
- # Now you have to do this
318
- authors = Author.where(name: 'Hank Moody').to_a
319
- authors.compact!
320
- ```
321
-
322
- ### Changes on Default Scopes
323
-
324
- Default scopes are no longer overriden by chained conditions.
325
-
326
- In previous versions when you defined a `default_scope` in a model
327
- it was overriden by chained conditions in the same field. Now it
328
- is merged like any other scope.
329
-
330
- Before:
331
-
332
- ```ruby
333
- class User < ActiveRecord::Base
334
- default_scope { where state: 'pending' }
335
- scope :active, -> { where state: 'active' }
336
- scope :inactive, -> { where state: 'inactive' }
337
- end
338
-
339
- User.all
340
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
341
-
342
- User.active
343
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
344
-
345
- User.where(state: 'inactive')
346
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
347
- ```
348
-
349
- After:
350
-
351
- ```ruby
352
- class User < ActiveRecord::Base
353
- default_scope { where state: 'pending' }
354
- scope :active, -> { where state: 'active' }
355
- scope :inactive, -> { where state: 'inactive' }
356
- end
357
-
358
- User.all
359
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
360
-
361
- User.active
362
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'active'
363
-
364
- User.where(state: 'inactive')
365
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending' AND "users"."state" = 'inactive'
366
- ```
367
-
368
- To get the previous behavior it is needed to explicitly remove the
369
- `default_scope` condition using `unscoped`, `unscope`, `rewhere` or
370
- `except`.
371
-
372
- ```ruby
373
- class User < ActiveRecord::Base
374
- default_scope { where state: 'pending' }
375
- scope :active, -> { unscope(where: :state).where(state: 'active') }
376
- scope :inactive, -> { rewhere state: 'inactive' }
377
- end
378
-
379
- User.all
380
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'pending'
381
-
382
- User.active
383
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'active'
384
-
385
- User.inactive
386
- # SELECT "users".* FROM "users" WHERE "users"."state" = 'inactive'
387
- ```
388
-
389
- ### Rendering content from string
390
-
391
- Rails 4.1 introduces `:plain`, `:html`, and `:body` options to `render`. Those
392
- options are now the preferred way to render string-based content, as it allows
393
- you to specify which content type you want the response sent as.
394
-
395
- * `render :plain` will set the content type to `text/plain`
396
- * `render :html` will set the content type to `text/html`
397
- * `render :body` will *not* set the content type header.
398
-
399
- From the security standpoint, if you don't expect to have any markup in your
400
- response body, you should be using `render :plain` as most browsers will escape
401
- unsafe content in the response for you.
402
-
403
- We will be deprecating the use of `render :text` in a future version. So please
404
- start using the more precise `:plain:`, `:html`, and `:body` options instead.
405
- Using `render :text` may pose a security risk, as the content is sent as
406
- `text/html`.
407
-
408
- ### PostgreSQL json and hstore datatypes
409
-
410
- Rails 4.1 will map `json` and `hstore` columns to a string-keyed Ruby `Hash`.
411
- In earlier versions a `HashWithIndifferentAccess` was used. This means that
412
- symbol access is no longer supported. This is also the case for
413
- `store_accessors` based on top of `json` or `hstore` columns. Make sure to use
414
- string keys consistently.
415
-
416
- ### Explicit block use for `ActiveSupport::Callbacks`
417
-
418
- Rails 4.1 now expects an explicit block to be passed when calling
419
- `ActiveSupport::Callbacks.set_callback`. This change stems from
420
- `ActiveSupport::Callbacks` being largely rewritten for the 4.1 release.
421
-
422
- ```ruby
423
- # Previously in Rails 4.0
424
- set_callback :save, :around, ->(r, &block) { stuff; result = block.call; stuff }
425
-
426
- # Now in Rails 4.1
427
- set_callback :save, :around, ->(r, block) { stuff; result = block.call; stuff }
428
- ```
429
-
430
- Upgrading from Rails 3.2 to Rails 4.0
431
- -------------------------------------
432
-
433
- If your application is currently on any version of Rails older than 3.2.x, you should upgrade to Rails 3.2 before attempting one to Rails 4.0.
434
-
435
- The following changes are meant for upgrading your application to Rails 4.0.
436
-
437
- ### HTTP PATCH
438
-
439
- Rails 4 now uses `PATCH` as the primary HTTP verb for updates when a RESTful
440
- resource is declared in `config/routes.rb`. The `update` action is still used,
441
- and `PUT` requests will continue to be routed to the `update` action as well.
442
- So, if you're using only the standard RESTful routes, no changes need to be made:
443
-
444
- ```ruby
445
- resources :users
446
- ```
447
-
448
- ```erb
449
- <%= form_for @user do |f| %>
450
- ```
451
-
452
- ```ruby
453
- class UsersController < ApplicationController
454
- def update
455
- # No change needed; PATCH will be preferred, and PUT will still work.
456
- end
457
- end
458
- ```
459
-
460
- However, you will need to make a change if you are using `form_for` to update
461
- a resource in conjunction with a custom route using the `PUT` HTTP method:
462
-
463
- ```ruby
464
- resources :users, do
465
- put :update_name, on: :member
466
- end
467
- ```
468
-
469
- ```erb
470
- <%= form_for [ :update_name, @user ] do |f| %>
471
- ```
472
-
473
- ```ruby
474
- class UsersController < ApplicationController
475
- def update_name
476
- # Change needed; form_for will try to use a non-existent PATCH route.
477
- end
478
- end
479
- ```
480
-
481
- If the action is not being used in a public API and you are free to change the
482
- HTTP method, you can update your route to use `patch` instead of `put`:
483
-
484
- `PUT` requests to `/users/:id` in Rails 4 get routed to `update` as they are
485
- today. So, if you have an API that gets real PUT requests it is going to work.
486
- The router also routes `PATCH` requests to `/users/:id` to the `update` action.
487
-
488
- ```ruby
489
- resources :users do
490
- patch :update_name, on: :member
491
- end
492
- ```
493
-
494
- If the action is being used in a public API and you can't change to HTTP method
495
- being used, you can update your form to use the `PUT` method instead:
496
-
497
- ```erb
498
- <%= form_for [ :update_name, @user ], method: :put do |f| %>
499
- ```
500
-
501
- For more on PATCH and why this change was made, see [this post](http://weblog.rubyonrails.org/2012/2/26/edge-rails-patch-is-the-new-primary-http-method-for-updates/)
502
- on the Rails blog.
503
-
504
- #### A note about media types
505
-
506
- The errata for the `PATCH` verb [specifies that a 'diff' media type should be
507
- used with `PATCH`](http://www.rfc-editor.org/errata_search.php?rfc=5789). One
508
- such format is [JSON Patch](http://tools.ietf.org/html/rfc6902). While Rails
509
- does not support JSON Patch natively, it's easy enough to add support:
510
-
511
- ```
512
- # in your controller
513
- def update
514
- respond_to do |format|
515
- format.json do
516
- # perform a partial update
517
- @post.update params[:post]
518
- end
519
-
520
- format.json_patch do
521
- # perform sophisticated change
522
- end
523
- end
524
- end
525
-
526
- # In config/initializers/json_patch.rb:
527
- Mime::Type.register 'application/json-patch+json', :json_patch
528
- ```
529
-
530
- As JSON Patch was only recently made into an RFC, there aren't a lot of great
531
- Ruby libraries yet. Aaron Patterson's
532
- [hana](https://github.com/tenderlove/hana) is one such gem, but doesn't have
533
- full support for the last few changes in the specification.
534
-
535
- ### Gemfile
536
-
537
- Rails 4.0 removed the `assets` group from Gemfile. You'd need to remove that
538
- line from your Gemfile when upgrading. You should also update your application
539
- file (in `config/application.rb`):
540
-
541
- ```ruby
542
- # Require the gems listed in Gemfile, including any gems
543
- # you've limited to :test, :development, or :production.
544
- Bundler.require(*Rails.groups)
545
- ```
546
-
547
- ### vendor/plugins
548
-
549
- Rails 4.0 no longer supports loading plugins from `vendor/plugins`. You must replace any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, `lib/my_plugin/*` and add an appropriate initializer in `config/initializers/my_plugin.rb`.
550
-
551
- ### Active Record
552
-
553
- * Rails 4.0 has removed the identity map from Active Record, due to [some inconsistencies with associations](https://github.com/rails/rails/commit/302c912bf6bcd0fa200d964ec2dc4a44abe328a6). If you have manually enabled it in your application, you will have to remove the following config that has no effect anymore: `config.active_record.identity_map`.
554
-
555
- * The `delete` method in collection associations can now receive `Fixnum` or `String` arguments as record ids, besides records, pretty much like the `destroy` method does. Previously it raised `ActiveRecord::AssociationTypeMismatch` for such arguments. From Rails 4.0 on `delete` automatically tries to find the records matching the given ids before deleting them.
556
-
557
- * In Rails 4.0 when a column or a table is renamed the related indexes are also renamed. If you have migrations which rename the indexes, they are no longer needed.
558
-
559
- * Rails 4.0 has changed `serialized_attributes` and `attr_readonly` to class methods only. You shouldn't use instance methods since it's now deprecated. You should change them to use class methods, e.g. `self.serialized_attributes` to `self.class.serialized_attributes`.
560
-
561
- * When using the default coder, assigning `nil` to a serialized attribute will save it
562
- to the database as `NULL` instead of passing the `nil` value through YAML (`"--- \n...\n"`).
563
-
564
- * Rails 4.0 has removed `attr_accessible` and `attr_protected` feature in favor of Strong Parameters. You can use the [Protected Attributes gem](https://github.com/rails/protected_attributes) for a smooth upgrade path.
565
-
566
- * If you are not using Protected Attributes, you can remove any options related to
567
- this gem such as `whitelist_attributes` or `mass_assignment_sanitizer` options.
568
-
569
- * Rails 4.0 requires that scopes use a callable object such as a Proc or lambda:
570
-
571
- ```ruby
572
- scope :active, where(active: true)
573
-
574
- # becomes
575
- scope :active, -> { where active: true }
576
- ```
577
-
578
- * Rails 4.0 has deprecated `ActiveRecord::Fixtures` in favor of `ActiveRecord::FixtureSet`.
579
-
580
- * Rails 4.0 has deprecated `ActiveRecord::TestCase` in favor of `ActiveSupport::TestCase`.
581
-
582
- * Rails 4.0 has deprecated the old-style hash based finder API. This means that
583
- methods which previously accepted "finder options" no longer do.
584
-
585
- * All dynamic methods except for `find_by_...` and `find_by_...!` are deprecated.
586
- Here's how you can handle the changes:
587
-
588
- * `find_all_by_...` becomes `where(...)`.
589
- * `find_last_by_...` becomes `where(...).last`.
590
- * `scoped_by_...` becomes `where(...)`.
591
- * `find_or_initialize_by_...` becomes `find_or_initialize_by(...)`.
592
- * `find_or_create_by_...` becomes `find_or_create_by(...)`.
593
-
594
- * Note that `where(...)` returns a relation, not an array like the old finders. If you require an `Array`, use `where(...).to_a`.
595
-
596
- * These equivalent methods may not execute the same SQL as the previous implementation.
597
-
598
- * To re-enable the old finders, you can use the [activerecord-deprecated_finders gem](https://github.com/rails/activerecord-deprecated_finders).
599
-
600
- ### Active Resource
601
-
602
- Rails 4.0 extracted Active Resource to its own gem. If you still need the feature you can add the [Active Resource gem](https://github.com/rails/activeresource) in your Gemfile.
603
-
604
- ### Active Model
605
-
606
- * Rails 4.0 has changed how errors attach with the `ActiveModel::Validations::ConfirmationValidator`. Now when confirmation validations fail, the error will be attached to `:#{attribute}_confirmation` instead of `attribute`.
607
-
608
- * Rails 4.0 has changed `ActiveModel::Serializers::JSON.include_root_in_json` default value to `false`. Now, Active Model Serializers and Active Record objects have the same default behaviour. This means that you can comment or remove the following option in the `config/initializers/wrap_parameters.rb` file:
609
-
610
- ```ruby
611
- # Disable root element in JSON by default.
612
- # ActiveSupport.on_load(:active_record) do
613
- # self.include_root_in_json = false
614
- # end
615
- ```
616
-
617
- ### Action Pack
618
-
619
- * Rails 4.0 introduces `ActiveSupport::KeyGenerator` and uses this as a base from which to generate and verify signed cookies (among other things). Existing signed cookies generated with Rails 3.x will be transparently upgraded if you leave your existing `secret_token` in place and add the new `secret_key_base`.
620
-
621
- ```ruby
622
- # config/initializers/secret_token.rb
623
- Myapp::Application.config.secret_token = 'existing secret token'
624
- Myapp::Application.config.secret_key_base = 'new secret key base'
625
- ```
626
-
627
- Please note that you should wait to set `secret_key_base` until you have 100% of your userbase on Rails 4.x and are reasonably sure you will not need to rollback to Rails 3.x. This is because cookies signed based on the new `secret_key_base` in Rails 4.x are not backwards compatible with Rails 3.x. You are free to leave your existing `secret_token` in place, not set the new `secret_key_base`, and ignore the deprecation warnings until you are reasonably sure that your upgrade is otherwise complete.
628
-
629
- If you are relying on the ability for external applications or Javascript to be able to read your Rails app's signed session cookies (or signed cookies in general) you should not set `secret_key_base` until you have decoupled these concerns.
630
-
631
- * Rails 4.0 encrypts the contents of cookie-based sessions if `secret_key_base` has been set. Rails 3.x signed, but did not encrypt, the contents of cookie-based session. Signed cookies are "secure" in that they are verified to have been generated by your app and are tamper-proof. However, the contents can be viewed by end users, and encrypting the contents eliminates this caveat/concern without a significant performance penalty.
632
-
633
- Please read [Pull Request #9978](https://github.com/rails/rails/pull/9978) for details on the move to encrypted session cookies.
634
-
635
- * Rails 4.0 removed the `ActionController::Base.asset_path` option. Use the assets pipeline feature.
636
-
637
- * Rails 4.0 has deprecated `ActionController::Base.page_cache_extension` option. Use `ActionController::Base.default_static_extension` instead.
638
-
639
- * Rails 4.0 has removed Action and Page caching from Action Pack. You will need to add the `actionpack-action_caching` gem in order to use `caches_action` and the `actionpack-page_caching` to use `caches_pages` in your controllers.
640
-
641
- * Rails 4.0 has removed the XML parameters parser. You will need to add the `actionpack-xml_parser` gem if you require this feature.
642
-
643
- * Rails 4.0 changes the default memcached client from `memcache-client` to `dalli`. To upgrade, simply add `gem 'dalli'` to your `Gemfile`.
644
-
645
- * Rails 4.0 deprecates the `dom_id` and `dom_class` methods in controllers (they are fine in views). You will need to include the `ActionView::RecordIdentifier` module in controllers requiring this feature.
646
-
647
- * Rails 4.0 deprecates the `:confirm` option for the `link_to` helper. You should
648
- instead rely on a data attribute (e.g. `data: { confirm: 'Are you sure?' }`).
649
- This deprecation also concerns the helpers based on this one (such as `link_to_if`
650
- or `link_to_unless`).
651
-
652
- * Rails 4.0 changed how `assert_generates`, `assert_recognizes`, and `assert_routing` work. Now all these assertions raise `Assertion` instead of `ActionController::RoutingError`.
653
-
654
- * Rails 4.0 raises an `ArgumentError` if clashing named routes are defined. This can be triggered by explicitly defined named routes or by the `resources` method. Here are two examples that clash with routes named `example_path`:
655
-
656
- ```ruby
657
- get 'one' => 'test#example', as: :example
658
- get 'two' => 'test#example', as: :example
659
- ```
660
-
661
- ```ruby
662
- resources :examples
663
- get 'clashing/:id' => 'test#example', as: :example
664
- ```
665
-
666
- In the first case, you can simply avoid using the same name for multiple
667
- routes. In the second, you can use the `only` or `except` options provided by
668
- the `resources` method to restrict the routes created as detailed in the
669
- [Routing Guide](routing.html#restricting-the-routes-created).
670
-
671
- * Rails 4.0 also changed the way unicode character routes are drawn. Now you can draw unicode character routes directly. If you already draw such routes, you must change them, for example:
672
-
673
- ```ruby
674
- get Rack::Utils.escape('こんにちは'), controller: 'welcome', action: 'index'
675
- ```
676
-
677
- becomes
678
-
679
- ```ruby
680
- get 'こんにちは', controller: 'welcome', action: 'index'
681
- ```
682
-
683
- * Rails 4.0 requires that routes using `match` must specify the request method. For example:
684
-
685
- ```ruby
686
- # Rails 3.x
687
- match '/' => 'root#index'
688
-
689
- # becomes
690
- match '/' => 'root#index', via: :get
691
-
692
- # or
693
- get '/' => 'root#index'
694
- ```
695
-
696
- * Rails 4.0 has removed `ActionDispatch::BestStandardsSupport` middleware, `<!DOCTYPE html>` already triggers standards mode per http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx and ChromeFrame header has been moved to `config.action_dispatch.default_headers`.
697
-
698
- Remember you must also remove any references to the middleware from your application code, for example:
699
-
700
- ```ruby
701
- # Raise exception
702
- config.middleware.insert_before(Rack::Lock, ActionDispatch::BestStandardsSupport)
703
- ```
704
-
705
- Also check your environment settings for `config.action_dispatch.best_standards_support` and remove it if present.
706
-
707
- * In Rails 4.0, precompiling assets no longer automatically copies non-JS/CSS assets from `vendor/assets` and `lib/assets`. Rails application and engine developers should put these assets in `app/assets` or configure `config.assets.precompile`.
708
-
709
- * In Rails 4.0, `ActionController::UnknownFormat` is raised when the action doesn't handle the request format. By default, the exception is handled by responding with 406 Not Acceptable, but you can override that now. In Rails 3, 406 Not Acceptable was always returned. No overrides.
710
-
711
- * In Rails 4.0, a generic `ActionDispatch::ParamsParser::ParseError` exception is raised when `ParamsParser` fails to parse request params. You will want to rescue this exception instead of the low-level `MultiJson::DecodeError`, for example.
712
-
713
- * In Rails 4.0, `SCRIPT_NAME` is properly nested when engines are mounted on an app that's served from a URL prefix. You no longer have to set `default_url_options[:script_name]` to work around overwritten URL prefixes.
714
-
715
- * Rails 4.0 deprecated `ActionController::Integration` in favor of `ActionDispatch::Integration`.
716
- * Rails 4.0 deprecated `ActionController::IntegrationTest` in favor of `ActionDispatch::IntegrationTest`.
717
- * Rails 4.0 deprecated `ActionController::PerformanceTest` in favor of `ActionDispatch::PerformanceTest`.
718
- * Rails 4.0 deprecated `ActionController::AbstractRequest` in favor of `ActionDispatch::Request`.
719
- * Rails 4.0 deprecated `ActionController::Request` in favor of `ActionDispatch::Request`.
720
- * Rails 4.0 deprecated `ActionController::AbstractResponse` in favor of `ActionDispatch::Response`.
721
- * Rails 4.0 deprecated `ActionController::Response` in favor of `ActionDispatch::Response`.
722
- * Rails 4.0 deprecated `ActionController::Routing` in favor of `ActionDispatch::Routing`.
723
-
724
- ### Active Support
725
-
726
- Rails 4.0 removes the `j` alias for `ERB::Util#json_escape` since `j` is already used for `ActionView::Helpers::JavaScriptHelper#escape_javascript`.
727
-
728
- ### Helpers Loading Order
729
-
730
- The order in which helpers from more than one directory are loaded has changed in Rails 4.0. Previously, they were gathered and then sorted alphabetically. After upgrading to Rails 4.0, helpers will preserve the order of loaded directories and will be sorted alphabetically only within each directory. Unless you explicitly use the `helpers_path` parameter, this change will only impact the way of loading helpers from engines. If you rely on the ordering, you should check if correct methods are available after upgrade. If you would like to change the order in which engines are loaded, you can use `config.railties_order=` method.
731
-
732
- ### Active Record Observer and Action Controller Sweeper
733
-
734
- Active Record Observer and Action Controller Sweeper have been extracted to the `rails-observers` gem. You will need to add the `rails-observers` gem if you require these features.
735
-
736
- ### sprockets-rails
737
-
738
- * `assets:precompile:primary` and `assets:precompile:all` have been removed. Use `assets:precompile` instead.
739
- * The `config.assets.compress` option should be changed to `config.assets.js_compressor` like so for instance:
740
-
741
- ```ruby
742
- config.assets.js_compressor = :uglifier
743
- ```
744
-
745
- ### sass-rails
746
-
747
- * `asset-url` with two arguments is deprecated. For example: `asset-url("rails.png", image)` becomes `asset-url("rails.png")`.
748
-
749
- Upgrading from Rails 3.1 to Rails 3.2
750
- -------------------------------------
751
-
752
- If your application is currently on any version of Rails older than 3.1.x, you should upgrade to Rails 3.1 before attempting an update to Rails 3.2.
753
-
754
- The following changes are meant for upgrading your application to Rails 3.2.17,
755
- the last 3.2.x version of Rails.
756
-
757
- ### Gemfile
758
-
759
- Make the following changes to your `Gemfile`.
760
-
761
- ```ruby
762
- gem 'rails', '3.2.17'
763
-
764
- group :assets do
765
- gem 'sass-rails', '~> 3.2.6'
766
- gem 'coffee-rails', '~> 3.2.2'
767
- gem 'uglifier', '>= 1.0.3'
768
- end
769
- ```
770
-
771
- ### config/environments/development.rb
772
-
773
- There are a couple of new configuration settings that you should add to your development environment:
774
-
775
- ```ruby
776
- # Raise exception on mass assignment protection for Active Record models
777
- config.active_record.mass_assignment_sanitizer = :strict
778
-
779
- # Log the query plan for queries taking more than this (works
780
- # with SQLite, MySQL, and PostgreSQL)
781
- config.active_record.auto_explain_threshold_in_seconds = 0.5
782
- ```
783
-
784
- ### config/environments/test.rb
785
-
786
- The `mass_assignment_sanitizer` configuration setting should also be be added to `config/environments/test.rb`:
787
-
788
- ```ruby
789
- # Raise exception on mass assignment protection for Active Record models
790
- config.active_record.mass_assignment_sanitizer = :strict
791
- ```
792
-
793
- ### vendor/plugins
794
-
795
- Rails 3.2 deprecates `vendor/plugins` and Rails 4.0 will remove them completely. While it's not strictly necessary as part of a Rails 3.2 upgrade, you can start replacing any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, `lib/my_plugin/*` and add an appropriate initializer in `config/initializers/my_plugin.rb`.
796
-
797
- ### Active Record
798
-
799
- Option `:dependent => :restrict` has been removed from `belongs_to`. If you want to prevent deleting the object if there are any associated objects, you can set `:dependent => :destroy` and return `false` after checking for existence of association from any of the associated object's destroy callbacks.
800
-
801
- Upgrading from Rails 3.0 to Rails 3.1
802
- -------------------------------------
803
-
804
- If your application is currently on any version of Rails older than 3.0.x, you should upgrade to Rails 3.0 before attempting an update to Rails 3.1.
805
-
806
- The following changes are meant for upgrading your application to Rails 3.1.12, the last 3.1.x version of Rails.
807
-
808
- ### Gemfile
809
-
810
- Make the following changes to your `Gemfile`.
811
-
812
- ```ruby
813
- gem 'rails', '3.1.12'
814
- gem 'mysql2'
815
-
816
- # Needed for the new asset pipeline
817
- group :assets do
818
- gem 'sass-rails', '~> 3.1.7'
819
- gem 'coffee-rails', '~> 3.1.1'
820
- gem 'uglifier', '>= 1.0.3'
821
- end
822
-
823
- # jQuery is the default JavaScript library in Rails 3.1
824
- gem 'jquery-rails'
825
- ```
826
-
827
- ### config/application.rb
828
-
829
- The asset pipeline requires the following additions:
830
-
831
- ```ruby
832
- config.assets.enabled = true
833
- config.assets.version = '1.0'
834
- ```
835
-
836
- If your application is using an "/assets" route for a resource you may want change the prefix used for assets to avoid conflicts:
837
-
838
- ```ruby
839
- # Defaults to '/assets'
840
- config.assets.prefix = '/asset-files'
841
- ```
842
-
843
- ### config/environments/development.rb
844
-
845
- Remove the RJS setting `config.action_view.debug_rjs = true`.
846
-
847
- Add these settings if you enable the asset pipeline:
848
-
849
- ```ruby
850
- # Do not compress assets
851
- config.assets.compress = false
852
-
853
- # Expands the lines which load the assets
854
- config.assets.debug = true
855
- ```
856
-
857
- ### config/environments/production.rb
858
-
859
- Again, most of the changes below are for the asset pipeline. You can read more about these in the [Asset Pipeline](asset_pipeline.html) guide.
860
-
861
- ```ruby
862
- # Compress JavaScripts and CSS
863
- config.assets.compress = true
864
-
865
- # Don't fallback to assets pipeline if a precompiled asset is missed
866
- config.assets.compile = false
867
-
868
- # Generate digests for assets URLs
869
- config.assets.digest = true
870
-
871
- # Defaults to Rails.root.join("public/assets")
872
- # config.assets.manifest = YOUR_PATH
873
-
874
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
875
- # config.assets.precompile += %w( search.js )
876
-
877
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
878
- # config.force_ssl = true
879
- ```
880
-
881
- ### config/environments/test.rb
882
-
883
- You can help test performance with these additions to your test environment:
884
-
885
- ```ruby
886
- # Configure static asset server for tests with Cache-Control for performance
887
- config.serve_static_assets = true
888
- config.static_cache_control = 'public, max-age=3600'
889
- ```
890
-
891
- ### config/initializers/wrap_parameters.rb
892
-
893
- 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.
894
-
895
- ```ruby
896
- # Be sure to restart your server when you modify this file.
897
- # This file contains settings for ActionController::ParamsWrapper which
898
- # is enabled by default.
899
-
900
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
901
- ActiveSupport.on_load(:action_controller) do
902
- wrap_parameters format: [:json]
903
- end
904
-
905
- # Disable root element in JSON by default.
906
- ActiveSupport.on_load(:active_record) do
907
- self.include_root_in_json = false
908
- end
909
- ```
910
-
911
- ### config/initializers/session_store.rb
912
-
913
- You need to change your session key to something new, or remove all sessions:
914
-
915
- ```ruby
916
- # in config/initializers/session_store.rb
917
- AppName::Application.config.session_store :cookie_store, key: 'SOMETHINGNEW'
918
- ```
919
-
920
- or
921
-
922
- ```bash
923
- $ bin/rake db:sessions:clear
924
- ```
925
-
926
- ### Remove :cache and :concat options in asset helpers references in views
927
-
928
- * With the Asset Pipeline the :cache and :concat options aren't used anymore, delete these options from your views.