4_2_release_notes.md 23.9 KB
Newer Older
1 2 3 4 5
Ruby on Rails 4.2 Release Notes
===============================

Highlights in Rails 4.2:

6 7 8 9 10
* Active Job, Action Mailer #deliver_later
* Adequate Record
* Web Console
* Foreign key support

11 12 13 14
These release notes cover only the major changes. To learn about various bug
fixes and changes, please refer to the change logs or check out the [list of
commits](https://github.com/rails/rails/commits/master) in the main Rails
repository on GitHub.
15

16 17
--------------------------------------------------------------------------------

18
NOTE: This document is a work in progress, please help to improve this by sending
G
Godfrey Chan 已提交
19
a [pull request](https://github.com/rails/rails/edit/master/guides/source/4_2_release_notes.md).
20

21 22 23 24 25 26
Upgrading to Rails 4.2
----------------------

If you're upgrading an existing application, it's a great idea to have good test
coverage before going in. You should also first upgrade to Rails 4.1 in case you
haven't and make sure your application still runs as expected before attempting
J
Jon Atack 已提交
27
to upgrade to Rails 4.2. A list of things to watch out for when upgrading is
28
available in the
29
[Upgrading Ruby on Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2)
30 31 32 33 34 35
guide.


Major Features
--------------

36 37 38
### Active Job, Action Mailer #deliver_later

Active Job is a new framework in Rails 4.2. It is an adapter layer on top of
E
Eric Brooke 已提交
39
queuing systems like [Resque](https://github.com/resque/resque), [Delayed Job](https://github.com/collectiveidea/delayed_job), [Sidekiq](https://github.com/mperham/sidekiq), and more. You can write your
40 41
jobs with the Active Job API, and it'll run on all these queues with no changes
(it comes pre-configured with an inline runner).
42

43
Building on top of Active Job, Action Mailer now comes with a `#deliver_later`
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
method, which adds your email to be sent as a job to a queue, so it doesn't
bog down the controller or model.

The new GlobalID library makes it easy to pass Active Record objects to jobs by
serializing them in a generic form. This means you no longer have to manually
pack and unpack your Active Records by passing ids. Just give the job the
straight Active Record object, and it'll serialize it using GlobalID, and
deserialize it at run time.

### Adequate Record

Rails 4.2 comes with a performance improvement feature called Adequate Record
for Active Record. A lot of common queries are now up to twice as fast in Rails
4.2!

59
TODO: add some technical details
60 61 62 63 64 65

### Web Console

New applications generated from Rails 4.2 now comes with the Web Console gem by
default.

66 67 68
Web Console is a set of debugging tools for your Rails application. It will add
an interactive console on every error page, a `console` view helper and a VT100
compatible terminal.
69

70 71
The interactive console on the error pages lets you execute code where the
exception originated. It's quite handy to introspect the state that led to the
72 73
error.

74 75
The `console` view helper launches an interactive console within the context of
the view where it is invoked.
76

77
Finally, you can launch a VT100 terminal that runs `rails console`. If you need
78 79
to create or modify existing test data, you can do that straight from the
browser.
80

Y
Yves Senn 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
### Foreign key support

The migration DSL now supports adding and removing foreign keys. They are dumped
to `schema.rb` as well. At this time, only the `mysql`, `mysql2` and `postgresql`
adapters support foreign keys.

```ruby
# add a foreign key to `articles.author_id` referencing `authors.id`
add_foreign_key :articles, :authors

# add a foreign key to `articles.author_id` referencing `users.lng_id`
add_foreign_key :articles, :users, column: :author_id, primary_key: "lng_id"

# remove the foreign key on `accounts.branch_id`
remove_foreign_key :accounts, :branches

# remove the foreign key on `accounts.owner_id`
remove_foreign_key :accounts, column: :owner_id
```

See the API documentation on
[add_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_foreign_key)
and
[remove_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-remove_foreign_key)
for a full description.
106 107 108 109 110


Railties
--------

111
Please refer to the [Changelog][railties] for detailed changes.
112 113 114

### Removals

115 116
*   The `rails application` command has been removed without replacement.
    ([Pull Request](https://github.com/rails/rails/pull/11616))
117

118 119
### Deprecations

120 121
*   Deprecated `Rails::Rack::LogTailer` without replacement.
    ([Commit](https://github.com/rails/rails/commit/84a13e019e93efaa8994b3f8303d635a7702dbce))
122

123 124
### Notable changes

125
*   Introduced `web-console` in the default application Gemfile.
126
    ([Pull Request](https://github.com/rails/rails/pull/11667))
127

128 129 130
*   Added a `required` option to the model generator for associations.
    ([Pull Request](https://github.com/rails/rails/pull/16062))

J
Jon Atack 已提交
131
*   Introduced an `after_bundle` callback for use in Rails templates.
132 133
    ([Pull Request](https://github.com/rails/rails/pull/16359))

134
*   Introduced the `x` namespace for defining custom configuration options:
135

G
Godfrey Chan 已提交
136 137
    ```ruby
    # config/environments/production.rb
138 139
    config.x.payment_processing.schedule = :daily
    config.x.payment_processing.retries  = 3
140
    config.x.super_debugger              = true
G
Godfrey Chan 已提交
141
    ```
142 143 144

    These options are then available through the configuration object:

G
Godfrey Chan 已提交
145
    ```ruby
146 147 148
    Rails.configuration.x.payment_processing.schedule # => :daily
    Rails.configuration.x.payment_processing.retries  # => 3
    Rails.configuration.x.super_debugger              # => true
G
Godfrey Chan 已提交
149
    ```
150 151 152 153 154 155

    ([Commit](https://github.com/rails/rails/commit/611849772dd66c2e4d005dcfe153f7ce79a8a7db))

*   Introduced `Rails::Application.config_for` to load a configuration for the
    current environment.

G
Godfrey Chan 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168 169
    ```ruby
    # config/exception_notification.yml:
    production:
      url: http://127.0.0.1:8080
      namespace: my_app_production
    development:
      url: http://localhost:3001
      namespace: my_app_development

    # config/production.rb
    MyApp::Application.configure do
      config.middleware.use ExceptionNotifier, config_for(:exception_notification)
    end
    ```
170 171 172

    ([Pull Request](https://github.com/rails/rails/pull/16129))

J
Jon Atack 已提交
173
*   Introduced a `--skip-gems` option in the app generator to skip gems such as
J
Jake Worth 已提交
174
    `turbolinks` and `coffee-rails` that do not have their own specific flags.
175
    ([Commit](https://github.com/rails/rails/commit/10565895805887d4faf004a6f71219da177f78b7))
176

J
Jon Atack 已提交
177 178
*   Introduced a `bin/setup` script to enable automated setup code when
    bootstrapping an application.
179
    ([Pull Request](https://github.com/rails/rails/pull/15189))
180

181 182
*   Changed default value for `config.assets.digest` to `true` in development.
    ([Pull Request](https://github.com/rails/rails/pull/15155))
183

184 185 186
*   Introduced an API to register new extensions for `rake notes`.
    ([Pull Request](https://github.com/rails/rails/pull/14379))

187 188
*   Introduced `Rails.gem_version` as a convenience method to return
    `Gem::Version.new(Rails.version)`.
189
    ([Pull Request](https://github.com/rails/rails/pull/14101))
190 191 192 193 194


Action Pack
-----------

195
Please refer to the [Changelog][action-pack] for detailed changes.
196

197 198
### Removals

199
*   `respond_with` and the class-level `respond_to` were removed from Rails and
J
Jon Atack 已提交
200 201
    moved to the `responders` gem (version 2.0). Add `gem 'responders', '~> 2.0'`
    to your `Gemfile` to continue using these features.
202 203
    ([Pull Request](https://github.com/rails/rails/pull/16526))

204 205
*   Removed deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
    in favor of `AbstractController::Helpers::MissingHelperError`.
206
    ([Commit](https://github.com/rails/rails/commit/a1ddde15ae0d612ff2973de9cf768ed701b594e8))
207

208
### Deprecations
209

210 211 212 213
*   Deprecated `assert_tag`, `assert_no_tag`, `find_tag` and `find_all_tag` in
    favor of `assert_select`.
    ([Commit](https://github.com/rails/rails-dom-testing/commit/b12850bc5ff23ba4b599bf2770874dd4f11bf750))

214 215
*   Deprecated support for setting the `:to` option of a router to a symbol or a
    string that does not contain a `#` character:
216

217 218 219 220 221 222 223 224
    ```ruby
    get '/posts', to: MyRackApp    => (No change necessary)
    get '/posts', to: 'post#index' => (No change necessary)
    get '/posts', to: 'posts'      => get '/posts', controller: :posts
    get '/posts', to: :index       => get '/posts', action: :index
    ```

    ([Commit](https://github.com/rails/rails/commit/cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9))
225 226 227

### Notable changes

228 229 230
*   Rails will now automatically include the template's digest in ETags.
    ([Pull Request](https://github.com/rails/rails/pull/16527))

231 232 233
*   `render nothing: true` or rendering a `nil` body no longer add a single
    space padding to the response body.
    ([Pull Request](https://github.com/rails/rails/pull/14883))
234

235 236 237 238
*   Introduced the `always_permitted_parameters` option to configure which
    parameters are permitted globally. The default value of this configuration
    is `['controller', 'action']`.
    ([Pull Request](https://github.com/rails/rails/pull/15933))
239

J
Jon Atack 已提交
240 241
*   The `*_filter` family methods have been removed from the documentation. Their
    usage is discouraged in favor of the `*_action` family methods:
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264

    ```
    after_filter          => after_action
    append_after_filter   => append_after_action
    append_around_filter  => append_around_action
    append_before_filter  => append_before_action
    around_filter         => around_action
    before_filter         => before_action
    prepend_after_filter  => prepend_after_action
    prepend_around_filter => prepend_around_action
    prepend_before_filter => prepend_before_action
    skip_after_filter     => skip_after_action
    skip_around_filter    => skip_around_action
    skip_before_filter    => skip_before_action
    skip_filter           => skip_action_callback
    ```

    If your application is depending on these methods, you should use the
    replacement `*_action` methods instead. These methods will be deprecated in
    the future and eventually removed from Rails.

    (Commit [1](https://github.com/rails/rails/commit/6c5f43bab8206747a8591435b2aa0ff7051ad3de),
    [2](https://github.com/rails/rails/commit/489a8f2a44dc9cea09154ee1ee2557d1f037c7d4))
265

266 267
*   Added HTTP method `MKCALENDAR` from RFC-4791
    ([Pull Request](https://github.com/rails/rails/pull/15121))
268

269 270
*   `*_fragment.action_controller` notifications now include the controller
    and action name in the payload.
271
    ([Pull Request](https://github.com/rails/rails/pull/14137))
272

273 274
*   Segments that are passed into URL helpers are now automatically escaped.
    ([Commit](https://github.com/rails/rails/commit/5460591f0226a9d248b7b4f89186bd5553e7768f))
275

J
Jon Atack 已提交
276
*   Improved the Routing Error page with fuzzy matching for route search.
277
    ([Pull Request](https://github.com/rails/rails/pull/14619))
278

J
Jon Atack 已提交
279
*   Added an option to disable logging of CSRF failures.
280
    ([Pull Request](https://github.com/rails/rails/pull/14280))
281

282 283 284 285 286 287 288
*   When the Rails server is set to serve static assets, gzip assets will now be
    served if the client supports it and a pre-generated gzip file (.gz) is on disk.
    By default the asset pipeline generates `.gz` files for all compressible assets.
    Serving gzip files minimizes data transfer and speeds up asset requests. Always
    [use a CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns) if you are
    serving assets from your Rails server in production.
    ([Pull Request](https://github.com/rails/rails/pull/16466))
289

290 291 292
Action View
-------------

293
Please refer to the [Changelog][action-view] for detailed changes.
294 295 296

### Deprecations

297 298 299 300
*   Deprecated `AbstractController::Base.parent_prefixes`.
    Override `AbstractController::Base.local_prefixes` when you want to change
    where to find views.
    ([Pull Request](https://github.com/rails/rails/pull/15026))
301

J
Jon Atack 已提交
302 303
*   Deprecated `ActionView::Digestor#digest(name, format, finder, options = {})`.
    Arguments should be passed as a hash instead.
304
    ([Pull Request](https://github.com/rails/rails/pull/14243))
305 306 307

### Notable changes

308
*   Introduced a `#{partial_name}_iteration` special local variable for use with
J
Jon Atack 已提交
309
    partials that are rendered with a collection. It provides access to the
310 311 312 313
    current state of the iteration via the `#index`, `#size`, `#first?` and
    `#last?` methods.
    ([Pull Request](https://github.com/rails/rails/pull/7698))

314 315 316
*   The form helpers no longer generate a `<div>` element with inline CSS around
    the hidden fields.
    ([Pull Request](https://github.com/rails/rails/pull/14738))
317

318 319 320
*   Placeholder I18n follows the same convention as `label` I18n.
    ([Pull Request](https://github.com/rails/rails/pull/16438))

321

322 323 324
Action Mailer
-------------

325
Please refer to the [Changelog][action-mailer] for detailed changes.
326

327 328 329 330 331
### Deprecations

*   Deprecated `*_path` helpers in mailers. Always use `*_url` helpers instead.
    ([Pull Request](https://github.com/rails/rails/pull/15840))

332 333 334
*   Deprecated `deliver` / `deliver!` in favour of `deliver_now` / `deliver_now!`.
    ([Pull Request](https://github.com/rails/rails/pull/16582))

335 336
### Notable changes

337
*   Introduced `deliver_later` which enqueues a job on the application's queue
338
    to deliver emails asynchronously.
339 340
    ([Pull Request](https://github.com/rails/rails/pull/16485))

341 342 343
*   Added the `show_previews` configuration option for enabling mailer previews
    outside of the development environment.
    ([Pull Request](https://github.com/rails/rails/pull/15970))
344

345 346 347 348

Active Record
-------------

349
Please refer to the [Changelog][active-record] for detailed changes.
350

351 352
### Removals

353 354
*   Removed `cache_attributes` and friends. All attributes are cached.
    ([Pull Request](https://github.com/rails/rails/pull/15429))
355

356 357
*   Removed deprecated method `ActiveRecord::Base.quoted_locking_column`.
    ([Pull Request](https://github.com/rails/rails/pull/15612))
358

359 360 361
*   Removed deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
    `proper_table_name` instance method on `ActiveRecord::Migration` instead.
    ([Pull Request](https://github.com/rails/rails/pull/15512))
362

363 364
*   Removed unused `:timestamp` type. Transparently alias it to `:datetime`
    in all cases. Fixes inconsistencies when column types are sent outside of
365
    `ActiveRecord`, such as for XML serialization.
366
    ([Pull Request](https://github.com/rails/rails/pull/15184))
367

368 369
### Deprecations

G
Godfrey Chan 已提交
370 371 372 373 374 375 376 377 378 379 380
*   Deprecated swallowing of errors inside `after_commit` and `after_rollback`.
    ([Pull Request](https://github.com/rails/rails/pull/16537))

*   Deprecated calling `DatabaseTasks.load_schema` without a connection. Use
    `DatabaseTasks.load_schema_current` instead.
    ([Commit](https://github.com/rails/rails/commit/f15cef67f75e4b52fd45655d7c6ab6b35623c608))

*   Deprecated `Reflection#source_macro` without replacement as it is no longer
    needed in Active Record.
    ([Pull Request](https://github.com/rails/rails/pull/16373))

381 382 383 384 385
*   Deprecated broken support for automatic detection of counter caches on
    `has_many :through` associations. You should instead manually specify the
    counter cache on the `has_many` and `belongs_to` associations for the
    through records.
    ([Pull Request](https://github.com/rails/rails/pull/15754))
386

387 388
*   Deprecated `serialized_attributes` without replacement.
    ([Pull Request](https://github.com/rails/rails/pull/15704))
389

390 391 392
*   Deprecated returning `nil` from `column_for_attribute` when no column
    exists. It will return a null object in Rails 5.0
    ([Pull Request](https://github.com/rails/rails/pull/15878))
393

394 395 396 397
*   Deprecated using `.joins`, `.preload` and `.eager_load` with associations
    that depends on the instance state (i.e. those defined with a scope that
    takes an argument) without replacement.
    ([Commit](https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1))
398

399 400 401 402
*   Deprecated passing Active Record objects to `.find` or `.exists?`. Call
    `#id` on the objects first.
    (Commit [1](https://github.com/rails/rails/commit/d92ae6ccca3bcfd73546d612efaea011270bd270),
    [2](https://github.com/rails/rails/commit/d35f0033c7dec2b8d8b52058fb8db495d49596f7))
403

404 405 406 407
*   Deprecated half-baked support for PostgreSQL range values with excluding
    beginnings. We currently map PostgreSQL ranges to Ruby ranges. This conversion
    is not fully possible because the Ruby range does not support excluded
    beginnings.
408

409 410 411 412
    The current solution of incrementing the beginning is not correct
    and is now deprecated. For subtypes where we don't know how to increment
    (e.g. `#succ` is not defined) it will raise an `ArgumentError` for ranges
    with excluding beginnings.
413

414
    ([Commit](https://github.com/rails/rails/commit/91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3))
415

416 417
### Notable changes

G
Godfrey Chan 已提交
418 419 420 421 422 423 424
*   The PostgreSQL adapter now supports the `JSONB` datatype in PostgreSQL 9.4+.
    ([Pull Request](https://github.com/rails/rails/pull/16220))

*   The `#references` method in migrations now supports a `type` option for
    specifying the type of the foreign key (e.g. `:uuid`).
    ([Pull Request](https://github.com/rails/rails/pull/16231))

425 426 427
*   Added a `:required` option to singular associations, which defines a
    presence validation on the association.
    ([Pull Request](https://github.com/rails/rails/pull/16056))
428

429 430 431
*   Introduced `ActiveRecord::Base#validate!` that raises `RecordInvalid` if the
    record is invalid.
    ([Pull Request](https://github.com/rails/rails/pull/8639))
432

433 434 435 436
*   `ActiveRecord::Base#reload` now behaves the same as `m = Model.find(m.id)`,
    meaning that it no longer retains the extra attributes from custom
    `select`s.
    ([Pull Request](https://github.com/rails/rails/pull/15866))
437

438 439 440
*   Introduced the `bin/rake db:purge` task to empty the database for the
    current environment.
    ([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d))
441

442 443 444 445 446 447 448
*   `ActiveRecord::Dirty` now detects in-place changes to mutable values.
    Serialized attributes on ActiveRecord models will no longer save when
    unchanged. This also works with other types such as string columns and json
    columns on PostgreSQL.
    (Pull Requests [1](https://github.com/rails/rails/pull/15674),
    [2](https://github.com/rails/rails/pull/15786),
    [3](https://github.com/rails/rails/pull/15788))
449

450 451
*   Added support for `#pretty_print` in `ActiveRecord::Base` objects.
    ([Pull Request](https://github.com/rails/rails/pull/15172))
452

453 454 455
*   PostgreSQL and SQLite adapters no longer add a default limit of 255
    characters on string columns.
    ([Pull Request](https://github.com/rails/rails/pull/14579))
456

457 458 459
*   `sqlite3:///some/path` now resolves to the absolute system path
    `/some/path`. For relative paths, use `sqlite3:some/path` instead.
    (Previously, `sqlite3:///some/path` resolved to the relative path
460
    `some/path`. This behaviour was deprecated on Rails 4.1).
461
    ([Pull Request](https://github.com/rails/rails/pull/14569))
462

463 464
*   Introduced `#validate` as an alias for `#valid?`.
    ([Pull Request](https://github.com/rails/rails/pull/14456))
465

466 467
*   `#touch` now accepts multiple attributes to be touched at once.
    ([Pull Request](https://github.com/rails/rails/pull/14423))
468

469 470 471
*   Added support for fractional seconds for MySQL 5.6 and above.
    (Pull Request [1](https://github.com/rails/rails/pull/8240),
    [2](https://github.com/rails/rails/pull/14359))
472

473 474
*   Added support for the `citext` column type in PostgreSQL adapter.
    ([Pull Request](https://github.com/rails/rails/pull/12523))
475

476 477
*   Added support for user-created range types in PostgreSQL adapter.
    ([Commit](https://github.com/rails/rails/commit/4cb47167e747e8f9dc12b0ddaf82bdb68c03e032))
478

479

480 481 482
Active Model
------------

483
Please refer to the [Changelog][active-model] for detailed changes.
484

485 486
### Removals

487
*   Removed deprecated `Validator#setup` without replacement.
488 489 490 491
    ([Pull Request](https://github.com/rails/rails/pull/10716))

### Deprecations

492
*   Deprecated `reset_#{attribute}` in favor of `restore_#{attribute}`.
493 494
    ([Pull Request](https://github.com/rails/rails/pull/16180))

495 496
*   Deprecated `ActiveModel::Dirty#reset_changes` in favor of
    `#clear_changes_information`.
497
    ([Pull Request](https://github.com/rails/rails/pull/16180))
498

499 500
### Notable changes

501 502
*   Introduced the `restore_attributes` method in `ActiveModel::Dirty` to restore
    the changed (dirty) attributes to their previous values.
503 504
    (Pull Request [1](https://github.com/rails/rails/pull/14861),
    [2](https://github.com/rails/rails/pull/16180))
505 506 507 508

*   `has_secure_password` no longer disallow blank passwords (i.e. passwords
    that contains only spaces) by default.
    ([Pull Request](https://github.com/rails/rails/pull/16412))
509

510 511 512
*   `has_secure_password` now verifies that the given password is less than 72
    characters if validations are enabled.
    ([Pull Request](https://github.com/rails/rails/pull/15708))
513

514 515
*   Introduced `#validate` as an alias for `#valid?`.
    ([Pull Request](https://github.com/rails/rails/pull/14456))
516 517 518 519 520


Active Support
--------------

521
Please refer to the [Changelog][active-support] for detailed changes.
522 523 524

### Removals

525 526 527
*   Removed deprecated `Numeric#ago`, `Numeric#until`, `Numeric#since`,
    `Numeric#from_now`.
    ([Commit](https://github.com/rails/rails/commit/f1eddea1e3f6faf93581c43651348f48b2b7d8bb))
528

529 530
*   Removed deprecated string based terminators for `ActiveSupport::Callbacks`.
    ([Pull Request](https://github.com/rails/rails/pull/15100))
531 532 533

### Deprecations

534 535 536 537
*   Deprecated `Kernel#silence_stderr`, `Kernel#capture` and `Kernel#quietly`
    without replacement.
    ([Pull Request](https://github.com/rails/rails/pull/13392))

538 539 540
*   Deprecated `Class#superclass_delegating_accessor`, use
    `Class#class_attribute` instead.
    ([Pull Request](https://github.com/rails/rails/pull/14271))
541

542 543 544
*   Deprecated `ActiveSupport::SafeBuffer#prepend!` as
    `ActiveSupport::SafeBuffer#prepend` now performs the same function.
    ([Pull Request](https://github.com/rails/rails/pull/14529))
545 546 547

### Notable changes

548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
*   The `travel_to` test helper now truncates the `usec` component to 0.
    ([Commit](https://github.com/rails/rails/commit/9f6e82ee4783e491c20f5244a613fdeb4024beb5))

*   `ActiveSupport::TestCase` now randomizes the order that test cases are ran
    by default.
    ([Commit](https://github.com/rails/rails/commit/6ffb29d24e05abbd9ffe3ea974140d6c70221807))

*   Introduced `Object#itself` as an identity function.
    (Commit [1](https://github.com/rails/rails/commit/702ad710b57bef45b081ebf42e6fa70820fdd810),
    [2](https://github.com/rails/rails/commit/64d91122222c11ad3918cc8e2e3ebc4b0a03448a))

*   `Object#with_options` can now be used without an explicit receiver.
    ([Pull Request](https://github.com/rails/rails/pull/16339))

*   Introduced `String#truncate_words` to truncate a string by a number of words.
    ([Pull Request](https://github.com/rails/rails/pull/16190))

565 566 567 568
*   Added `Hash#transform_values` and `Hash#transform_values!` to simplify a
    common pattern where the values of a hash must change, but the keys are left
    the same.
    ([Pull Request](https://github.com/rails/rails/pull/15819))
569

570 571
*   The `humanize` inflector helper now strips any leading underscores.
    ([Commit](https://github.com/rails/rails/commit/daaa21bc7d20f2e4ff451637423a25ff2d5e75c7))
572

J
Jon Atack 已提交
573
*   Introduced `Concern#class_methods` as an alternative to
574 575 576
    `module ClassMethods`, as well as `Kernel#concern` to avoid the
    `module Foo; extend ActiveSupport::Concern; end` boilerplate.
    ([Commit](https://github.com/rails/rails/commit/b16c36e688970df2f96f793a759365b248b582ad))
577

578

579 580 581 582 583
Credits
-------

See the
[full list of contributors to Rails](http://contributors.rubyonrails.org/) for
584 585
the many people who spent many hours making Rails the stable and robust
framework it is today. Kudos to all of them.
586 587 588 589 590 591 592 593

[railties]:       https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md
[action-pack]:    https://github.com/rails/rails/blob/4-2-stable/actionpack/CHANGELOG.md
[action-view]:    https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md
[action-mailer]:  https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md
[active-record]:  https://github.com/rails/rails/blob/4-2-stable/activerecord/CHANGELOG.md
[active-model]:   https://github.com/rails/rails/blob/4-2-stable/activemodel/CHANGELOG.md
[active-support]: https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md