rails 4.1.16 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -10
  3. data/guides/CHANGELOG.md +15 -100
  4. data/guides/Rakefile +5 -3
  5. data/guides/assets/javascripts/guides.js +6 -0
  6. data/guides/assets/stylesheets/main.css +4 -1
  7. data/guides/bug_report_templates/action_controller_master.rb +1 -0
  8. data/guides/rails_guides/helpers.rb +1 -1
  9. data/guides/rails_guides/levenshtein.rb +29 -21
  10. data/guides/rails_guides/markdown/renderer.rb +1 -1
  11. data/guides/rails_guides/markdown.rb +11 -7
  12. data/guides/rails_guides.rb +2 -2
  13. data/guides/source/2_2_release_notes.md +1 -1
  14. data/guides/source/2_3_release_notes.md +4 -4
  15. data/guides/source/3_0_release_notes.md +8 -8
  16. data/guides/source/3_1_release_notes.md +6 -3
  17. data/guides/source/3_2_release_notes.md +6 -3
  18. data/guides/source/4_0_release_notes.md +6 -3
  19. data/guides/source/4_1_release_notes.md +5 -6
  20. data/guides/source/4_2_release_notes.md +850 -0
  21. data/guides/source/_license.html.erb +1 -1
  22. data/guides/source/_welcome.html.erb +2 -8
  23. data/guides/source/action_controller_overview.md +81 -7
  24. data/guides/source/action_mailer_basics.md +91 -28
  25. data/guides/source/action_view_overview.md +148 -130
  26. data/guides/source/active_job_basics.md +318 -0
  27. data/guides/source/active_model_basics.md +371 -17
  28. data/guides/source/active_record_basics.md +19 -18
  29. data/guides/source/active_record_callbacks.md +12 -9
  30. data/guides/source/{migrations.md → active_record_migrations.md} +95 -220
  31. data/guides/source/active_record_postgresql.md +433 -0
  32. data/guides/source/active_record_querying.md +263 -265
  33. data/guides/source/active_record_validations.md +20 -11
  34. data/guides/source/active_support_core_extensions.md +159 -72
  35. data/guides/source/active_support_instrumentation.md +10 -7
  36. data/guides/source/api_documentation_guidelines.md +62 -16
  37. data/guides/source/asset_pipeline.md +258 -63
  38. data/guides/source/association_basics.md +81 -74
  39. data/guides/source/caching_with_rails.md +32 -7
  40. data/guides/source/command_line.md +52 -30
  41. data/guides/source/configuring.md +132 -29
  42. data/guides/source/constant_autoloading_and_reloading.md +1297 -0
  43. data/guides/source/contributing_to_ruby_on_rails.md +192 -112
  44. data/guides/source/credits.html.erb +2 -2
  45. data/guides/source/debugging_rails_applications.md +440 -286
  46. data/guides/source/development_dependencies_install.md +47 -36
  47. data/guides/source/documents.yaml +19 -7
  48. data/guides/source/engines.md +182 -182
  49. data/guides/source/form_helpers.md +79 -56
  50. data/guides/source/generators.md +24 -11
  51. data/guides/source/getting_started.md +337 -198
  52. data/guides/source/i18n.md +108 -65
  53. data/guides/source/index.html.erb +1 -0
  54. data/guides/source/initialization.md +108 -61
  55. data/guides/source/layout.html.erb +1 -4
  56. data/guides/source/layouts_and_rendering.md +27 -25
  57. data/guides/source/maintenance_policy.md +6 -3
  58. data/guides/source/nested_model_forms.md +7 -4
  59. data/guides/source/plugins.md +27 -27
  60. data/guides/source/rails_application_templates.md +21 -3
  61. data/guides/source/rails_on_rack.md +8 -4
  62. data/guides/source/routing.md +98 -72
  63. data/guides/source/ruby_on_rails_guides_guidelines.md +11 -12
  64. data/guides/source/security.md +38 -32
  65. data/guides/source/testing.md +188 -117
  66. data/guides/source/upgrading_ruby_on_rails.md +254 -28
  67. data/guides/source/working_with_javascript_in_rails.md +18 -16
  68. data/guides/w3c_validator.rb +2 -0
  69. metadata +40 -96
  70. data/guides/bug_report_templates/generic_gem.rb +0 -15
  71. data/guides/bug_report_templates/generic_master.rb +0 -26
  72. data/guides/code/getting_started/Gemfile +0 -40
  73. data/guides/code/getting_started/Gemfile.lock +0 -125
  74. data/guides/code/getting_started/README.rdoc +0 -28
  75. data/guides/code/getting_started/Rakefile +0 -6
  76. data/guides/code/getting_started/app/assets/javascripts/application.js +0 -15
  77. data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +0 -3
  78. data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +0 -3
  79. data/guides/code/getting_started/app/assets/javascripts/welcome.js.coffee +0 -3
  80. data/guides/code/getting_started/app/assets/stylesheets/application.css +0 -13
  81. data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +0 -3
  82. data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +0 -3
  83. data/guides/code/getting_started/app/assets/stylesheets/welcome.css.scss +0 -3
  84. data/guides/code/getting_started/app/controllers/application_controller.rb +0 -5
  85. data/guides/code/getting_started/app/controllers/comments_controller.rb +0 -23
  86. data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -53
  87. data/guides/code/getting_started/app/controllers/welcome_controller.rb +0 -4
  88. data/guides/code/getting_started/app/helpers/application_helper.rb +0 -2
  89. data/guides/code/getting_started/app/helpers/comments_helper.rb +0 -2
  90. data/guides/code/getting_started/app/helpers/posts_helper.rb +0 -2
  91. data/guides/code/getting_started/app/helpers/welcome_helper.rb +0 -2
  92. data/guides/code/getting_started/app/models/comment.rb +0 -3
  93. data/guides/code/getting_started/app/models/post.rb +0 -7
  94. data/guides/code/getting_started/app/views/comments/_comment.html.erb +0 -15
  95. data/guides/code/getting_started/app/views/comments/_form.html.erb +0 -13
  96. data/guides/code/getting_started/app/views/layouts/application.html.erb +0 -14
  97. data/guides/code/getting_started/app/views/posts/_form.html.erb +0 -27
  98. data/guides/code/getting_started/app/views/posts/edit.html.erb +0 -5
  99. data/guides/code/getting_started/app/views/posts/index.html.erb +0 -21
  100. data/guides/code/getting_started/app/views/posts/new.html.erb +0 -5
  101. data/guides/code/getting_started/app/views/posts/show.html.erb +0 -18
  102. data/guides/code/getting_started/app/views/welcome/index.html.erb +0 -4
  103. data/guides/code/getting_started/bin/bundle +0 -4
  104. data/guides/code/getting_started/bin/rails +0 -4
  105. data/guides/code/getting_started/bin/rake +0 -4
  106. data/guides/code/getting_started/config/application.rb +0 -18
  107. data/guides/code/getting_started/config/boot.rb +0 -4
  108. data/guides/code/getting_started/config/database.yml +0 -25
  109. data/guides/code/getting_started/config/environment.rb +0 -5
  110. data/guides/code/getting_started/config/environments/development.rb +0 -30
  111. data/guides/code/getting_started/config/environments/production.rb +0 -80
  112. data/guides/code/getting_started/config/environments/test.rb +0 -36
  113. data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +0 -7
  114. data/guides/code/getting_started/config/initializers/filter_parameter_logging.rb +0 -4
  115. data/guides/code/getting_started/config/initializers/inflections.rb +0 -16
  116. data/guides/code/getting_started/config/initializers/locale.rb +0 -9
  117. data/guides/code/getting_started/config/initializers/mime_types.rb +0 -5
  118. data/guides/code/getting_started/config/initializers/secret_token.rb +0 -12
  119. data/guides/code/getting_started/config/initializers/session_store.rb +0 -3
  120. data/guides/code/getting_started/config/initializers/wrap_parameters.rb +0 -14
  121. data/guides/code/getting_started/config/locales/en.yml +0 -23
  122. data/guides/code/getting_started/config/routes.rb +0 -7
  123. data/guides/code/getting_started/config.ru +0 -4
  124. data/guides/code/getting_started/db/migrate/20130122042648_create_posts.rb +0 -10
  125. data/guides/code/getting_started/db/migrate/20130122045842_create_comments.rb +0 -11
  126. data/guides/code/getting_started/db/schema.rb +0 -33
  127. data/guides/code/getting_started/db/seeds.rb +0 -7
  128. data/guides/code/getting_started/public/404.html +0 -60
  129. data/guides/code/getting_started/public/422.html +0 -60
  130. data/guides/code/getting_started/public/500.html +0 -59
  131. data/guides/code/getting_started/public/favicon.ico +0 -0
  132. data/guides/code/getting_started/public/robots.txt +0 -5
  133. data/guides/code/getting_started/test/controllers/comments_controller_test.rb +0 -7
  134. data/guides/code/getting_started/test/controllers/posts_controller_test.rb +0 -7
  135. data/guides/code/getting_started/test/controllers/welcome_controller_test.rb +0 -9
  136. data/guides/code/getting_started/test/fixtures/comments.yml +0 -11
  137. data/guides/code/getting_started/test/fixtures/posts.yml +0 -9
  138. data/guides/code/getting_started/test/helpers/comments_helper_test.rb +0 -4
  139. data/guides/code/getting_started/test/helpers/posts_helper_test.rb +0 -4
  140. data/guides/code/getting_started/test/helpers/welcome_helper_test.rb +0 -4
  141. data/guides/code/getting_started/test/models/comment_test.rb +0 -7
  142. data/guides/code/getting_started/test/models/post_test.rb +0 -7
  143. data/guides/code/getting_started/test/test_helper.rb +0 -12
@@ -0,0 +1,850 @@
1
+ Ruby on Rails 4.2 Release Notes
2
+ ===============================
3
+
4
+ Highlights in Rails 4.2:
5
+
6
+ * Active Job
7
+ * Asynchronous mails
8
+ * Adequate Record
9
+ * Web Console
10
+ * Foreign key support
11
+
12
+ These release notes cover only the major changes. To learn about other
13
+ features, bug fixes, and changes, please refer to the changelogs or check out
14
+ the [list of commits](https://github.com/rails/rails/commits/4-2-stable) in
15
+ the main Rails repository on GitHub.
16
+
17
+ --------------------------------------------------------------------------------
18
+
19
+ Upgrading to Rails 4.2
20
+ ----------------------
21
+
22
+ If you're upgrading an existing application, it's a great idea to have good test
23
+ coverage before going in. You should also first upgrade to Rails 4.1 in case you
24
+ haven't and make sure your application still runs as expected before attempting
25
+ to upgrade to Rails 4.2. A list of things to watch out for when upgrading is
26
+ available in the guide [Upgrading Ruby on
27
+ Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2).
28
+
29
+
30
+ Major Features
31
+ --------------
32
+
33
+ ### Active Job
34
+
35
+ Active Job is a new framework in Rails 4.2. It is a common interface on top of
36
+ queuing systems like [Resque](https://github.com/resque/resque), [Delayed
37
+ Job](https://github.com/collectiveidea/delayed_job),
38
+ [Sidekiq](https://github.com/mperham/sidekiq), and more.
39
+
40
+ Jobs written with the Active Job API run on any of the supported queues thanks
41
+ to their respective adapters. Active Job comes pre-configured with an inline
42
+ runner that executes jobs right away.
43
+
44
+ Jobs often need to take Active Record objects as arguments. Active Job passes
45
+ object references as URIs (uniform resource identifiers) instead of marshaling
46
+ the object itself. The new [Global ID](https://github.com/rails/globalid)
47
+ library builds URIs and looks up the objects they reference. Passing Active
48
+ Record objects as job arguments just works by using Global ID internally.
49
+
50
+ For example, if `trashable` is an Active Record object, then this job runs
51
+ just fine with no serialization involved:
52
+
53
+ ```ruby
54
+ class TrashableCleanupJob < ActiveJob::Base
55
+ def perform(trashable, depth)
56
+ trashable.cleanup(depth)
57
+ end
58
+ end
59
+ ```
60
+
61
+ See the [Active Job Basics](active_job_basics.html) guide for more
62
+ information.
63
+
64
+ ### Asynchronous Mails
65
+
66
+ Building on top of Active Job, Action Mailer now comes with a `deliver_later`
67
+ method that sends emails via the queue, so it doesn't block the controller or
68
+ model if the queue is asynchronous (the default inline queue blocks).
69
+
70
+ Sending emails right away is still possible with `deliver_now`.
71
+
72
+ ### Adequate Record
73
+
74
+ Adequate Record is a set of performance improvements in Active Record that makes
75
+ common `find` and `find_by` calls and some association queries up to 2x faster.
76
+
77
+ It works by caching common SQL queries as prepared statements and reusing them
78
+ on similar calls, skipping most of the query-generation work on subsequent
79
+ calls. For more details, please refer to [Aaron Patterson's blog
80
+ post](http://tenderlovemaking.com/2014/02/19/adequaterecord-pro-like-activerecord.html).
81
+
82
+ Active Record will automatically take advantage of this feature on
83
+ supported operations without any user involvement or code changes. Here are
84
+ some examples of supported operations:
85
+
86
+ ```ruby
87
+ Post.find(1) # First call generates and cache the prepared statement
88
+ Post.find(2) # Subsequent calls reuse the cached prepared statement
89
+
90
+ Post.find_by_title('first post')
91
+ Post.find_by_title('second post')
92
+
93
+ post.comments
94
+ post.comments(true)
95
+ ```
96
+
97
+ It's important to highlight that, as the examples above suggest, the prepared
98
+ statements do not cache the values passed in the method calls; rather, they
99
+ have placeholders for them.
100
+
101
+ Caching is not used in the following scenarios:
102
+
103
+ - The model has a default scope
104
+ - The model uses single table inheritance
105
+ - `find` with a list of ids, e.g.:
106
+
107
+ ```ruby
108
+ # not cached
109
+ Post.find(1, 2, 3)
110
+ Post.find([1,2])
111
+ ```
112
+
113
+ - `find_by` with SQL fragments:
114
+
115
+ ```ruby
116
+ Post.find_by('published_at < ?', 2.weeks.ago)
117
+ ```
118
+
119
+ ### Web Console
120
+
121
+ New applications generated with Rails 4.2 now come with the [Web
122
+ Console](https://github.com/rails/web-console) gem by default. Web Console adds
123
+ an interactive Ruby console on every error page and provides a `console` view
124
+ and controller helpers.
125
+
126
+ The interactive console on error pages lets you execute code in the context of
127
+ the place where the exception originated. The `console` helper, if called
128
+ anywhere in a view or controller, launches an interactive console with the final
129
+ context, once rendering has completed.
130
+
131
+ ### Foreign Key Support
132
+
133
+ The migration DSL now supports adding and removing foreign keys. They are dumped
134
+ to `schema.rb` as well. At this time, only the `mysql`, `mysql2` and `postgresql`
135
+ adapters support foreign keys.
136
+
137
+ ```ruby
138
+ # add a foreign key to `articles.author_id` referencing `authors.id`
139
+ add_foreign_key :articles, :authors
140
+
141
+ # add a foreign key to `articles.author_id` referencing `users.lng_id`
142
+ add_foreign_key :articles, :users, column: :author_id, primary_key: "lng_id"
143
+
144
+ # remove the foreign key on `accounts.branch_id`
145
+ remove_foreign_key :accounts, :branches
146
+
147
+ # remove the foreign key on `accounts.owner_id`
148
+ remove_foreign_key :accounts, column: :owner_id
149
+ ```
150
+
151
+ See the API documentation on
152
+ [add_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_foreign_key)
153
+ and
154
+ [remove_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-remove_foreign_key)
155
+ for a full description.
156
+
157
+
158
+ Incompatibilities
159
+ -----------------
160
+
161
+ Previously deprecated functionality has been removed. Please refer to the
162
+ individual components for new deprecations in this release.
163
+
164
+ The following changes may require immediate action upon upgrade.
165
+
166
+ ### `render` with a String Argument
167
+
168
+ Previously, calling `render "foo/bar"` in a controller action was equivalent to
169
+ `render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
170
+ `render template: "foo/bar"` instead. If you need to render a file, please
171
+ change your code to use the explicit form (`render file: "foo/bar"`) instead.
172
+
173
+ ### `respond_with` / Class-Level `respond_to`
174
+
175
+ `respond_with` and the corresponding class-level `respond_to` have been moved
176
+ to the [responders](https://github.com/plataformatec/responders) gem. Add
177
+ `gem 'responders', '~> 2.0'` to your Gemfile to use it:
178
+
179
+ ```ruby
180
+ # app/controllers/users_controller.rb
181
+
182
+ class UsersController < ApplicationController
183
+ respond_to :html, :json
184
+
185
+ def show
186
+ @user = User.find(params[:id])
187
+ respond_with @user
188
+ end
189
+ end
190
+ ```
191
+
192
+ Instance-level `respond_to` is unaffected:
193
+
194
+ ```ruby
195
+ # app/controllers/users_controller.rb
196
+
197
+ class UsersController < ApplicationController
198
+ def show
199
+ @user = User.find(params[:id])
200
+ respond_to do |format|
201
+ format.html
202
+ format.json { render json: @user }
203
+ end
204
+ end
205
+ end
206
+ ```
207
+
208
+ ### Default Host for `rails server`
209
+
210
+ Due to a [change in Rack](https://github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc),
211
+ `rails server` now listens on `localhost` instead of `0.0.0.0` by default. This
212
+ should have minimal impact on the standard development workflow as both
213
+ http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before
214
+ on your own machine.
215
+
216
+ However, with this change you will no longer be able to access the Rails
217
+ server from a different machine, for example if your development environment
218
+ is in a virtual machine and you would like to access it from the host machine.
219
+ In such cases, please start the server with `rails server -b 0.0.0.0` to
220
+ restore the old behavior.
221
+
222
+ If you do this, be sure to configure your firewall properly such that only
223
+ trusted machines on your network can access your development server.
224
+
225
+ ### HTML Sanitizer
226
+
227
+ The HTML sanitizer has been replaced with a new, more robust, implementation
228
+ built upon [Loofah](https://github.com/flavorjones/loofah) and
229
+ [Nokogiri](https://github.com/sparklemotion/nokogiri). The new sanitizer is
230
+ more secure and its sanitization is more powerful and flexible.
231
+
232
+ Due to the new algorithm, the sanitized output may be different for certain
233
+ pathological inputs.
234
+
235
+ If you have a particular need for the exact output of the old sanitizer, you
236
+ can add the [rails-deprecated_sanitizer](https://github.com/kaspth/rails-deprecated_sanitizer)
237
+ gem to the `Gemfile`, to have the old behavior. The gem does not issue
238
+ deprecation warnings because it is opt-in.
239
+
240
+ `rails-deprecated_sanitizer` will be supported for Rails 4.2 only; it will not
241
+ be maintained for Rails 5.0.
242
+
243
+ See [this blog post](http://blog.plataformatec.com.br/2014/07/the-new-html-sanitizer-in-rails-4-2/)
244
+ for more details on the changes in the new sanitizer.
245
+
246
+ ### `assert_select`
247
+
248
+ `assert_select` is now based on [Nokogiri](https://github.com/sparklemotion/nokogiri).
249
+ As a result, some previously-valid selectors are now unsupported. If your
250
+ application is using any of these spellings, you will need to update them:
251
+
252
+ * Values in attribute selectors may need to be quoted if they contain
253
+ non-alphanumeric characters.
254
+
255
+ ```
256
+ # before
257
+ a[href=/]
258
+ a[href$=/]
259
+
260
+ # now
261
+ a[href="/"]
262
+ a[href$="/"]
263
+ ```
264
+
265
+ * DOMs built from HTML source containing invalid HTML with improperly
266
+ nested elements may differ.
267
+
268
+ For example:
269
+
270
+ ``` ruby
271
+ # content: <div><i><p></i></div>
272
+
273
+ # before:
274
+ assert_select('div > i') # => true
275
+ assert_select('div > p') # => false
276
+ assert_select('i > p') # => true
277
+
278
+ # now:
279
+ assert_select('div > i') # => true
280
+ assert_select('div > p') # => true
281
+ assert_select('i > p') # => false
282
+ ```
283
+
284
+ * If the data selected contains entities, the value selected for comparison
285
+ used to be raw (e.g. `AT&amp;T`), and now is evaluated
286
+ (e.g. `AT&T`).
287
+
288
+ ``` ruby
289
+ # content: <p>AT&amp;T</p>
290
+
291
+ # before:
292
+ assert_select('p', 'AT&amp;T') # => true
293
+ assert_select('p', 'AT&T') # => false
294
+
295
+ # now:
296
+ assert_select('p', 'AT&T') # => true
297
+ assert_select('p', 'AT&amp;T') # => false
298
+ ```
299
+
300
+
301
+ Railties
302
+ --------
303
+
304
+ Please refer to the [Changelog][railties] for detailed changes.
305
+
306
+ ### Removals
307
+
308
+ * The `--skip-action-view` option has been removed from the
309
+ app generator. ([Pull Request](https://github.com/rails/rails/pull/17042))
310
+
311
+ * The `rails application` command has been removed without replacement.
312
+ ([Pull Request](https://github.com/rails/rails/pull/11616))
313
+
314
+ ### Deprecations
315
+
316
+ * Deprecated missing `config.log_level` for production environments.
317
+ ([Pull Request](https://github.com/rails/rails/pull/16622))
318
+
319
+ * Deprecated `rake test:all` in favor of `rake test` as it now run all tests
320
+ in the `test` folder.
321
+ ([Pull Request](https://github.com/rails/rails/pull/17348))
322
+
323
+ * Deprecated `rake test:all:db` in favor of `rake test:db`.
324
+ ([Pull Request](https://github.com/rails/rails/pull/17348))
325
+
326
+ * Deprecated `Rails::Rack::LogTailer` without replacement.
327
+ ([Commit](https://github.com/rails/rails/commit/84a13e019e93efaa8994b3f8303d635a7702dbce))
328
+
329
+ ### Notable changes
330
+
331
+ * Introduced `web-console` in the default application Gemfile.
332
+ ([Pull Request](https://github.com/rails/rails/pull/11667))
333
+
334
+ * Added a `required` option to the model generator for associations.
335
+ ([Pull Request](https://github.com/rails/rails/pull/16062))
336
+
337
+ * Introduced the `x` namespace for defining custom configuration options:
338
+
339
+ ```ruby
340
+ # config/environments/production.rb
341
+ config.x.payment_processing.schedule = :daily
342
+ config.x.payment_processing.retries = 3
343
+ config.x.super_debugger = true
344
+ ```
345
+
346
+ These options are then available through the configuration object:
347
+
348
+ ```ruby
349
+ Rails.configuration.x.payment_processing.schedule # => :daily
350
+ Rails.configuration.x.payment_processing.retries # => 3
351
+ Rails.configuration.x.super_debugger # => true
352
+ ```
353
+
354
+ ([Commit](https://github.com/rails/rails/commit/611849772dd66c2e4d005dcfe153f7ce79a8a7db))
355
+
356
+ * Introduced `Rails::Application.config_for` to load a configuration for the
357
+ current environment.
358
+
359
+ ```ruby
360
+ # config/exception_notification.yml:
361
+ production:
362
+ url: http://127.0.0.1:8080
363
+ namespace: my_app_production
364
+ development:
365
+ url: http://localhost:3001
366
+ namespace: my_app_development
367
+
368
+ # config/production.rb
369
+ Rails.application.configure do
370
+ config.middleware.use ExceptionNotifier, config_for(:exception_notification)
371
+ end
372
+ ```
373
+
374
+ ([Pull Request](https://github.com/rails/rails/pull/16129))
375
+
376
+ * Introduced a `--skip-turbolinks` option in the app generator to not generate
377
+ turbolinks integration.
378
+ ([Commit](https://github.com/rails/rails/commit/bf17c8a531bc8059d50ad731398002a3e7162a7d))
379
+
380
+ * Introduced a `bin/setup` script as a convention for automated setup code when
381
+ bootstrapping an application.
382
+ ([Pull Request](https://github.com/rails/rails/pull/15189))
383
+
384
+ * Changed the default value for `config.assets.digest` to `true` in development.
385
+ ([Pull Request](https://github.com/rails/rails/pull/15155))
386
+
387
+ * Introduced an API to register new extensions for `rake notes`.
388
+ ([Pull Request](https://github.com/rails/rails/pull/14379))
389
+
390
+ * Introduced an `after_bundle` callback for use in Rails templates.
391
+ ([Pull Request](https://github.com/rails/rails/pull/16359))
392
+
393
+ * Introduced `Rails.gem_version` as a convenience method to return
394
+ `Gem::Version.new(Rails.version)`.
395
+ ([Pull Request](https://github.com/rails/rails/pull/14101))
396
+
397
+
398
+ Action Pack
399
+ -----------
400
+
401
+ Please refer to the [Changelog][action-pack] for detailed changes.
402
+
403
+ ### Removals
404
+
405
+ * `respond_with` and the class-level `respond_to` have been removed from Rails and
406
+ moved to the `responders` gem (version 2.0). Add `gem 'responders', '~> 2.0'`
407
+ to your `Gemfile` to continue using these features.
408
+ ([Pull Request](https://github.com/rails/rails/pull/16526),
409
+ [More Details](http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#responders))
410
+
411
+ * Removed deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
412
+ in favor of `AbstractController::Helpers::MissingHelperError`.
413
+ ([Commit](https://github.com/rails/rails/commit/a1ddde15ae0d612ff2973de9cf768ed701b594e8))
414
+
415
+ ### Deprecations
416
+
417
+ * Deprecated the `only_path` option on `*_path` helpers.
418
+ ([Commit](https://github.com/rails/rails/commit/aa1fadd48fb40dd9396a383696134a259aa59db9))
419
+
420
+ * Deprecated `assert_tag`, `assert_no_tag`, `find_tag` and `find_all_tag` in
421
+ favor of `assert_select`.
422
+ ([Commit](https://github.com/rails/rails-dom-testing/commit/b12850bc5ff23ba4b599bf2770874dd4f11bf750))
423
+
424
+ * Deprecated support for setting the `:to` option of a router to a symbol or a
425
+ string that does not contain a "#" character:
426
+
427
+ ```ruby
428
+ get '/posts', to: MyRackApp => (No change necessary)
429
+ get '/posts', to: 'post#index' => (No change necessary)
430
+ get '/posts', to: 'posts' => get '/posts', controller: :posts
431
+ get '/posts', to: :index => get '/posts', action: :index
432
+ ```
433
+
434
+ ([Commit](https://github.com/rails/rails/commit/cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9))
435
+
436
+ * Deprecated support for string keys in URL helpers:
437
+
438
+ ```ruby
439
+ # bad
440
+ root_path('controller' => 'posts', 'action' => 'index')
441
+
442
+ # good
443
+ root_path(controller: 'posts', action: 'index')
444
+ ```
445
+
446
+ ([Pull Request](https://github.com/rails/rails/pull/17743))
447
+
448
+ ### Notable changes
449
+
450
+ * The `*_filter` family of methods have been removed from the documentation. Their
451
+ usage is discouraged in favor of the `*_action` family of methods:
452
+
453
+ ```
454
+ after_filter => after_action
455
+ append_after_filter => append_after_action
456
+ append_around_filter => append_around_action
457
+ append_before_filter => append_before_action
458
+ around_filter => around_action
459
+ before_filter => before_action
460
+ prepend_after_filter => prepend_after_action
461
+ prepend_around_filter => prepend_around_action
462
+ prepend_before_filter => prepend_before_action
463
+ skip_after_filter => skip_after_action
464
+ skip_around_filter => skip_around_action
465
+ skip_before_filter => skip_before_action
466
+ skip_filter => skip_action_callback
467
+ ```
468
+
469
+ If your application currently depends on these methods, you should use the
470
+ replacement `*_action` methods instead. These methods will be deprecated in
471
+ the future and will eventually be removed from Rails.
472
+
473
+ (Commit [1](https://github.com/rails/rails/commit/6c5f43bab8206747a8591435b2aa0ff7051ad3de),
474
+ [2](https://github.com/rails/rails/commit/489a8f2a44dc9cea09154ee1ee2557d1f037c7d4))
475
+
476
+ * `render nothing: true` or rendering a `nil` body no longer add a single
477
+ space padding to the response body.
478
+ ([Pull Request](https://github.com/rails/rails/pull/14883))
479
+
480
+ * Rails now automatically includes the template's digest in ETags.
481
+ ([Pull Request](https://github.com/rails/rails/pull/16527))
482
+
483
+ * Segments that are passed into URL helpers are now automatically escaped.
484
+ ([Commit](https://github.com/rails/rails/commit/5460591f0226a9d248b7b4f89186bd5553e7768f))
485
+
486
+ * Introduced the `always_permitted_parameters` option to configure which
487
+ parameters are permitted globally. The default value of this configuration
488
+ is `['controller', 'action']`.
489
+ ([Pull Request](https://github.com/rails/rails/pull/15933))
490
+
491
+ * Added the HTTP method `MKCALENDAR` from [RFC 4791](https://tools.ietf.org/html/rfc4791).
492
+ ([Pull Request](https://github.com/rails/rails/pull/15121))
493
+
494
+ * `*_fragment.action_controller` notifications now include the controller
495
+ and action name in the payload.
496
+ ([Pull Request](https://github.com/rails/rails/pull/14137))
497
+
498
+ * Improved the Routing Error page with fuzzy matching for route search.
499
+ ([Pull Request](https://github.com/rails/rails/pull/14619))
500
+
501
+ * Added an option to disable logging of CSRF failures.
502
+ ([Pull Request](https://github.com/rails/rails/pull/14280))
503
+
504
+ * When the Rails server is set to serve static assets, gzip assets will now be
505
+ served if the client supports it and a pre-generated gzip file (`.gz`) is on disk.
506
+ By default the asset pipeline generates `.gz` files for all compressible assets.
507
+ Serving gzip files minimizes data transfer and speeds up asset requests. Always
508
+ [use a CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns) if you are
509
+ serving assets from your Rails server in production.
510
+ ([Pull Request](https://github.com/rails/rails/pull/16466))
511
+
512
+ * When calling the `process` helpers in an integration test the path needs to have
513
+ a leading slash. Previously you could omit it but that was a byproduct of the
514
+ implementation and not an intentional feature, e.g.:
515
+
516
+ ```ruby
517
+ test "list all posts" do
518
+ get "/posts"
519
+ assert_response :success
520
+ end
521
+ ```
522
+
523
+ Action View
524
+ -----------
525
+
526
+ Please refer to the [Changelog][action-view] for detailed changes.
527
+
528
+ ### Deprecations
529
+
530
+ * Deprecated `AbstractController::Base.parent_prefixes`.
531
+ Override `AbstractController::Base.local_prefixes` when you want to change
532
+ where to find views.
533
+ ([Pull Request](https://github.com/rails/rails/pull/15026))
534
+
535
+ * Deprecated `ActionView::Digestor#digest(name, format, finder, options = {})`.
536
+ Arguments should be passed as a hash instead.
537
+ ([Pull Request](https://github.com/rails/rails/pull/14243))
538
+
539
+ ### Notable changes
540
+
541
+ * `render "foo/bar"` now expands to `render template: "foo/bar"` instead of
542
+ `render file: "foo/bar"`.
543
+ ([Pull Request](https://github.com/rails/rails/pull/16888))
544
+
545
+ * The form helpers no longer generate a `<div>` element with inline CSS around
546
+ the hidden fields.
547
+ ([Pull Request](https://github.com/rails/rails/pull/14738))
548
+
549
+ * Introduced a `#{partial_name}_iteration` special local variable for use with
550
+ partials that are rendered with a collection. It provides access to the
551
+ current state of the iteration via the `index`, `size`, `first?` and
552
+ `last?` methods.
553
+ ([Pull Request](https://github.com/rails/rails/pull/7698))
554
+
555
+ * Placeholder I18n follows the same convention as `label` I18n.
556
+ ([Pull Request](https://github.com/rails/rails/pull/16438))
557
+
558
+
559
+ Action Mailer
560
+ -------------
561
+
562
+ Please refer to the [Changelog][action-mailer] for detailed changes.
563
+
564
+ ### Deprecations
565
+
566
+ * Deprecated `*_path` helpers in mailers. Always use `*_url` helpers instead.
567
+ ([Pull Request](https://github.com/rails/rails/pull/15840))
568
+
569
+ * Deprecated `deliver` / `deliver!` in favor of `deliver_now` / `deliver_now!`.
570
+ ([Pull Request](https://github.com/rails/rails/pull/16582))
571
+
572
+ ### Notable changes
573
+
574
+ * `link_to` and `url_for` generate absolute URLs by default in templates,
575
+ it is no longer needed to pass `only_path: false`.
576
+ ([Commit](https://github.com/rails/rails/commit/9685080a7677abfa5d288a81c3e078368c6bb67c))
577
+
578
+ * Introduced `deliver_later` which enqueues a job on the application's queue
579
+ to deliver emails asynchronously.
580
+ ([Pull Request](https://github.com/rails/rails/pull/16485))
581
+
582
+ * Added the `show_previews` configuration option for enabling mailer previews
583
+ outside of the development environment.
584
+ ([Pull Request](https://github.com/rails/rails/pull/15970))
585
+
586
+
587
+ Active Record
588
+ -------------
589
+
590
+ Please refer to the [Changelog][active-record] for detailed changes.
591
+
592
+ ### Removals
593
+
594
+ * Removed `cache_attributes` and friends. All attributes are cached.
595
+ ([Pull Request](https://github.com/rails/rails/pull/15429))
596
+
597
+ * Removed deprecated method `ActiveRecord::Base.quoted_locking_column`.
598
+ ([Pull Request](https://github.com/rails/rails/pull/15612))
599
+
600
+ * Removed deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
601
+ `proper_table_name` instance method on `ActiveRecord::Migration` instead.
602
+ ([Pull Request](https://github.com/rails/rails/pull/15512))
603
+
604
+ * Removed unused `:timestamp` type. Transparently alias it to `:datetime`
605
+ in all cases. Fixes inconsistencies when column types are sent outside of
606
+ Active Record, such as for XML serialization.
607
+ ([Pull Request](https://github.com/rails/rails/pull/15184))
608
+
609
+ ### Deprecations
610
+
611
+ * Deprecated swallowing of errors inside `after_commit` and `after_rollback`.
612
+ ([Pull Request](https://github.com/rails/rails/pull/16537))
613
+
614
+ * Deprecated broken support for automatic detection of counter caches on
615
+ `has_many :through` associations. You should instead manually specify the
616
+ counter cache on the `has_many` and `belongs_to` associations for the
617
+ through records.
618
+ ([Pull Request](https://github.com/rails/rails/pull/15754))
619
+
620
+ * Deprecated passing Active Record objects to `.find` or `.exists?`. Call
621
+ `id` on the objects first.
622
+ (Commit [1](https://github.com/rails/rails/commit/d92ae6ccca3bcfd73546d612efaea011270bd270),
623
+ [2](https://github.com/rails/rails/commit/d35f0033c7dec2b8d8b52058fb8db495d49596f7))
624
+
625
+ * Deprecated half-baked support for PostgreSQL range values with excluding
626
+ beginnings. We currently map PostgreSQL ranges to Ruby ranges. This conversion
627
+ is not fully possible because Ruby ranges do not support excluded beginnings.
628
+
629
+ The current solution of incrementing the beginning is not correct
630
+ and is now deprecated. For subtypes where we don't know how to increment
631
+ (e.g. `succ` is not defined) it will raise an `ArgumentError` for ranges
632
+ with excluding beginnings.
633
+ ([Commit](https://github.com/rails/rails/commit/91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3))
634
+
635
+ * Deprecated calling `DatabaseTasks.load_schema` without a connection. Use
636
+ `DatabaseTasks.load_schema_current` instead.
637
+ ([Commit](https://github.com/rails/rails/commit/f15cef67f75e4b52fd45655d7c6ab6b35623c608))
638
+
639
+ * Deprecated `sanitize_sql_hash_for_conditions` without replacement. Using a
640
+ `Relation` for performing queries and updates is the preferred API.
641
+ ([Commit](https://github.com/rails/rails/commit/d5902c9e))
642
+
643
+ * Deprecated `add_timestamps` and `t.timestamps` without passing the `:null`
644
+ option. The default of `null: true` will change in Rails 5 to `null: false`.
645
+ ([Pull Request](https://github.com/rails/rails/pull/16481))
646
+
647
+ * Deprecated `Reflection#source_macro` without replacement as it is no longer
648
+ needed in Active Record.
649
+ ([Pull Request](https://github.com/rails/rails/pull/16373))
650
+
651
+ * Deprecated `serialized_attributes` without replacement.
652
+ ([Pull Request](https://github.com/rails/rails/pull/15704))
653
+
654
+ * Deprecated returning `nil` from `column_for_attribute` when no column
655
+ exists. It will return a null object in Rails 5.0.
656
+ ([Pull Request](https://github.com/rails/rails/pull/15878))
657
+
658
+ * Deprecated using `.joins`, `.preload` and `.eager_load` with associations
659
+ that depend on the instance state (i.e. those defined with a scope that
660
+ takes an argument) without replacement.
661
+ ([Commit](https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1))
662
+
663
+ ### Notable changes
664
+
665
+ * `SchemaDumper` uses `force: :cascade` on `create_table`. This makes it
666
+ possible to reload a schema when foreign keys are in place.
667
+
668
+ * Added a `:required` option to singular associations, which defines a
669
+ presence validation on the association.
670
+ ([Pull Request](https://github.com/rails/rails/pull/16056))
671
+
672
+ * `ActiveRecord::Dirty` now detects in-place changes to mutable values.
673
+ Serialized attributes on Active Record models are no longer saved when
674
+ unchanged. This also works with other types such as string columns and json
675
+ columns on PostgreSQL.
676
+ (Pull Requests [1](https://github.com/rails/rails/pull/15674),
677
+ [2](https://github.com/rails/rails/pull/15786),
678
+ [3](https://github.com/rails/rails/pull/15788))
679
+
680
+ * Introduced the `db:purge` Rake task to empty the database for the
681
+ current environment.
682
+ ([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d))
683
+
684
+ * Introduced `ActiveRecord::Base#validate!` that raises
685
+ `ActiveRecord::RecordInvalid` if the record is invalid.
686
+ ([Pull Request](https://github.com/rails/rails/pull/8639))
687
+
688
+ * Introduced `validate` as an alias for `valid?`.
689
+ ([Pull Request](https://github.com/rails/rails/pull/14456))
690
+
691
+ * `touch` now accepts multiple attributes to be touched at once.
692
+ ([Pull Request](https://github.com/rails/rails/pull/14423))
693
+
694
+ * The PostgreSQL adapter now supports the `jsonb` datatype in PostgreSQL 9.4+.
695
+ ([Pull Request](https://github.com/rails/rails/pull/16220))
696
+
697
+ * The PostgreSQL and SQLite adapters no longer add a default limit of 255
698
+ characters on string columns.
699
+ ([Pull Request](https://github.com/rails/rails/pull/14579))
700
+
701
+ * Added support for the `citext` column type in the PostgreSQL adapter.
702
+ ([Pull Request](https://github.com/rails/rails/pull/12523))
703
+
704
+ * Added support for user-created range types in the PostgreSQL adapter.
705
+ ([Commit](https://github.com/rails/rails/commit/4cb47167e747e8f9dc12b0ddaf82bdb68c03e032))
706
+
707
+ * `sqlite3:///some/path` now resolves to the absolute system path
708
+ `/some/path`. For relative paths, use `sqlite3:some/path` instead.
709
+ (Previously, `sqlite3:///some/path` resolved to the relative path
710
+ `some/path`. This behavior was deprecated on Rails 4.1).
711
+ ([Pull Request](https://github.com/rails/rails/pull/14569))
712
+
713
+ * Added support for fractional seconds for MySQL 5.6 and above.
714
+ (Pull Request [1](https://github.com/rails/rails/pull/8240),
715
+ [2](https://github.com/rails/rails/pull/14359))
716
+
717
+ * Added `ActiveRecord::Base#pretty_print` to pretty print models.
718
+ ([Pull Request](https://github.com/rails/rails/pull/15172))
719
+
720
+ * `ActiveRecord::Base#reload` now behaves the same as `m = Model.find(m.id)`,
721
+ meaning that it no longer retains the extra attributes from custom
722
+ `SELECT`s.
723
+ ([Pull Request](https://github.com/rails/rails/pull/15866))
724
+
725
+ * `ActiveRecord::Base#reflections` now returns a hash with string keys instead
726
+ of symbol keys. ([Pull Request](https://github.com/rails/rails/pull/17718))
727
+
728
+ * The `references` method in migrations now supports a `type` option for
729
+ specifying the type of the foreign key (e.g. `:uuid`).
730
+ ([Pull Request](https://github.com/rails/rails/pull/16231))
731
+
732
+ Active Model
733
+ ------------
734
+
735
+ Please refer to the [Changelog][active-model] for detailed changes.
736
+
737
+ ### Removals
738
+
739
+ * Removed deprecated `Validator#setup` without replacement.
740
+ ([Pull Request](https://github.com/rails/rails/pull/10716))
741
+
742
+ ### Deprecations
743
+
744
+ * Deprecated `reset_#{attribute}` in favor of `restore_#{attribute}`.
745
+ ([Pull Request](https://github.com/rails/rails/pull/16180))
746
+
747
+ * Deprecated `ActiveModel::Dirty#reset_changes` in favor of
748
+ `clear_changes_information`.
749
+ ([Pull Request](https://github.com/rails/rails/pull/16180))
750
+
751
+ ### Notable changes
752
+
753
+ * Introduced `validate` as an alias for `valid?`.
754
+ ([Pull Request](https://github.com/rails/rails/pull/14456))
755
+
756
+ * Introduced the `restore_attributes` method in `ActiveModel::Dirty` to restore
757
+ the changed (dirty) attributes to their previous values.
758
+ (Pull Request [1](https://github.com/rails/rails/pull/14861),
759
+ [2](https://github.com/rails/rails/pull/16180))
760
+
761
+ * `has_secure_password` no longer disallows blank passwords (i.e. passwords
762
+ that contains only spaces) by default.
763
+ ([Pull Request](https://github.com/rails/rails/pull/16412))
764
+
765
+ * `has_secure_password` now verifies that the given password is less than 72
766
+ characters if validations are enabled.
767
+ ([Pull Request](https://github.com/rails/rails/pull/15708))
768
+
769
+ Active Support
770
+ --------------
771
+
772
+ Please refer to the [Changelog][active-support] for detailed changes.
773
+
774
+ ### Removals
775
+
776
+ * Removed deprecated `Numeric#ago`, `Numeric#until`, `Numeric#since`,
777
+ `Numeric#from_now`.
778
+ ([Commit](https://github.com/rails/rails/commit/f1eddea1e3f6faf93581c43651348f48b2b7d8bb))
779
+
780
+ * Removed deprecated string based terminators for `ActiveSupport::Callbacks`.
781
+ ([Pull Request](https://github.com/rails/rails/pull/15100))
782
+
783
+ ### Deprecations
784
+
785
+ * Deprecated `Kernel#silence_stderr`, `Kernel#capture` and `Kernel#quietly`
786
+ without replacement.
787
+ ([Pull Request](https://github.com/rails/rails/pull/13392))
788
+
789
+ * Deprecated `Class#superclass_delegating_accessor`, use
790
+ `Class#class_attribute` instead.
791
+ ([Pull Request](https://github.com/rails/rails/pull/14271))
792
+
793
+ * Deprecated `ActiveSupport::SafeBuffer#prepend!` as
794
+ `ActiveSupport::SafeBuffer#prepend` now performs the same function.
795
+ ([Pull Request](https://github.com/rails/rails/pull/14529))
796
+
797
+ ### Notable changes
798
+
799
+ * Introduced a new configuration option `active_support.test_order` for
800
+ specifying the order test cases are executed. This option currently defaults
801
+ to `:sorted` but will be changed to `:random` in Rails 5.0.
802
+ ([Commit](https://github.com/rails/rails/commit/53e877f7d9291b2bf0b8c425f9e32ef35829f35b))
803
+
804
+ * `Object#try` and `Object#try!` can now be used without an explicit receiver in the block.
805
+ ([Commit](https://github.com/rails/rails/commit/5e51bdda59c9ba8e5faf86294e3e431bd45f1830),
806
+ [Pull Request](https://github.com/rails/rails/pull/17361))
807
+
808
+ * The `travel_to` test helper now truncates the `usec` component to 0.
809
+ ([Commit](https://github.com/rails/rails/commit/9f6e82ee4783e491c20f5244a613fdeb4024beb5))
810
+
811
+ * Introduced `Object#itself` as an identity function.
812
+ (Commit [1](https://github.com/rails/rails/commit/702ad710b57bef45b081ebf42e6fa70820fdd810),
813
+ [2](https://github.com/rails/rails/commit/64d91122222c11ad3918cc8e2e3ebc4b0a03448a))
814
+
815
+ * `Object#with_options` can now be used without an explicit receiver in the block.
816
+ ([Pull Request](https://github.com/rails/rails/pull/16339))
817
+
818
+ * Introduced `String#truncate_words` to truncate a string by a number of words.
819
+ ([Pull Request](https://github.com/rails/rails/pull/16190))
820
+
821
+ * Added `Hash#transform_values` and `Hash#transform_values!` to simplify a
822
+ common pattern where the values of a hash must change, but the keys are left
823
+ the same.
824
+ ([Pull Request](https://github.com/rails/rails/pull/15819))
825
+
826
+ * The `humanize` inflector helper now strips any leading underscores.
827
+ ([Commit](https://github.com/rails/rails/commit/daaa21bc7d20f2e4ff451637423a25ff2d5e75c7))
828
+
829
+ * Introduced `Concern#class_methods` as an alternative to
830
+ `module ClassMethods`, as well as `Kernel#concern` to avoid the
831
+ `module Foo; extend ActiveSupport::Concern; end` boilerplate.
832
+ ([Commit](https://github.com/rails/rails/commit/b16c36e688970df2f96f793a759365b248b582ad))
833
+
834
+ * New [guide](constant_autoloading_and_reloading.html) about constant autoloading and reloading.
835
+
836
+ Credits
837
+ -------
838
+
839
+ See the
840
+ [full list of contributors to Rails](http://contributors.rubyonrails.org/) for
841
+ the many people who spent many hours making Rails the stable and robust
842
+ framework it is today. Kudos to all of them.
843
+
844
+ [railties]: https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md
845
+ [action-pack]: https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md
846
+ [action-view]: https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md
847
+ [action-mailer]: https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md
848
+ [active-record]: https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md
849
+ [active-model]: https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md
850
+ [active-support]: https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md