2015-01-14 01:22:13 -05:00
|
|
|
**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.**
|
2014-12-23 17:32:50 -05:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
Ruby on Rails 4.2 Release Notes
|
|
|
|
===============================
|
|
|
|
|
|
|
|
Highlights in Rails 4.2:
|
|
|
|
|
2014-11-27 03:18:01 -05:00
|
|
|
* Active Job
|
2014-11-27 17:54:09 -05:00
|
|
|
* Asynchronous mails
|
2014-08-19 21:39:41 -04:00
|
|
|
* Adequate Record
|
|
|
|
* Web Console
|
|
|
|
* Foreign key support
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
These release notes cover only the major changes. To learn about other
|
|
|
|
features, bug fixes, and changes, please refer to the changelogs or check out
|
|
|
|
the [list of commits](https://github.com/rails/rails/commits/4-2-stable) in
|
|
|
|
the main Rails repository on GitHub.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-19 22:06:12 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
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
|
2014-08-19 04:22:43 -04:00
|
|
|
to upgrade to Rails 4.2. A list of things to watch out for when upgrading is
|
2014-11-26 19:20:57 -05:00
|
|
|
available in the guide [Upgrading Ruby on
|
|
|
|
Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-1-to-rails-4-2).
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
Major Features
|
|
|
|
--------------
|
|
|
|
|
2014-11-27 03:18:01 -05:00
|
|
|
### Active Job
|
2014-08-19 21:39:41 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
Active Job is a new framework in Rails 4.2. It is a common interface on top of
|
2014-09-22 03:17:37 -04:00
|
|
|
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.
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
Jobs written with the Active Job API run on any of the supported queues thanks
|
|
|
|
to their respective adapters. Active Job comes pre-configured with an inline
|
|
|
|
runner that executes jobs right away.
|
2014-08-19 21:39:41 -04:00
|
|
|
|
2014-11-27 16:17:30 -05:00
|
|
|
Jobs often need to take Active Record objects as arguments. Active Job passes
|
2014-11-27 03:18:01 -05:00
|
|
|
object references as URIs (uniform resource identifiers) instead of marshaling
|
|
|
|
the object itself. The new [Global ID](https://github.com/rails/globalid)
|
|
|
|
library builds URIs and looks up the objects they reference. Passing Active
|
2014-11-27 16:17:30 -05:00
|
|
|
Record objects as job arguments just works by using Global ID internally.
|
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
For example, if `trashable` is an Active Record object, then this job runs
|
|
|
|
just fine with no serialization involved:
|
2014-11-27 16:17:30 -05:00
|
|
|
|
|
|
|
```ruby
|
|
|
|
class TrashableCleanupJob < ActiveJob::Base
|
|
|
|
def perform(trashable, depth)
|
|
|
|
trashable.cleanup(depth)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
See the [Active Job Basics](active_job_basics.html) guide for more
|
|
|
|
information.
|
2014-08-19 21:39:41 -04:00
|
|
|
|
2014-11-27 03:18:01 -05:00
|
|
|
### Asynchronous Mails
|
|
|
|
|
|
|
|
Building on top of Active Job, Action Mailer now comes with a `deliver_later`
|
|
|
|
method that sends emails via the queue, so it doesn't block the controller or
|
|
|
|
model if the queue is asynchronous (the default inline queue blocks).
|
|
|
|
|
|
|
|
Sending emails right away is still possible with `deliver_now`.
|
|
|
|
|
2014-08-19 21:39:41 -04:00
|
|
|
### Adequate Record
|
|
|
|
|
2014-11-25 06:55:15 -05:00
|
|
|
Adequate Record is a set of performance improvements in Active Record that makes
|
|
|
|
common `find` and `find_by` calls and some association queries up to 2x faster.
|
2014-08-19 21:39:41 -04:00
|
|
|
|
2014-11-25 06:55:15 -05:00
|
|
|
It works by caching common SQL queries as prepared statements and reusing them
|
|
|
|
on similar calls, skipping most of the query-generation work on subsequent
|
2014-11-26 19:20:57 -05:00
|
|
|
calls. For more details, please refer to [Aaron Patterson's blog
|
|
|
|
post](http://tenderlovemaking.com/2014/02/19/adequaterecord-pro-like-activerecord.html).
|
2014-09-16 14:23:02 -04:00
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
Active Record will automatically take advantage of this feature on
|
2014-11-26 19:20:57 -05:00
|
|
|
supported operations without any user involvement or code changes. Here are
|
2014-11-28 08:18:44 -05:00
|
|
|
some examples of supported operations:
|
2014-09-16 14:23:02 -04:00
|
|
|
|
|
|
|
```ruby
|
2014-11-26 19:20:57 -05:00
|
|
|
Post.find(1) # First call generates and cache the prepared statement
|
|
|
|
Post.find(2) # Subsequent calls reuse the cached prepared statement
|
2014-09-16 14:23:02 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
Post.find_by_title('first post')
|
|
|
|
Post.find_by_title('second post')
|
2014-09-16 14:23:02 -04:00
|
|
|
|
2015-01-04 17:53:40 -05:00
|
|
|
Post.find_by(title: 'first post')
|
|
|
|
Post.find_by(title: 'second post')
|
|
|
|
|
2014-11-25 06:55:15 -05:00
|
|
|
post.comments
|
|
|
|
post.comments(true)
|
2014-09-16 14:23:02 -04:00
|
|
|
```
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
It's important to highlight that, as the examples above suggest, the prepared
|
2014-11-28 08:18:44 -05:00
|
|
|
statements do not cache the values passed in the method calls; rather, they
|
2014-11-26 19:20:57 -05:00
|
|
|
have placeholders for them.
|
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
Caching is not used in the following scenarios:
|
2014-09-16 14:23:02 -04:00
|
|
|
|
|
|
|
- The model has a default scope
|
2014-11-26 19:20:57 -05:00
|
|
|
- The model uses single table inheritance
|
|
|
|
- `find` with a list of ids, e.g.:
|
2014-09-16 14:23:02 -04:00
|
|
|
|
|
|
|
```ruby
|
2014-11-26 19:20:57 -05:00
|
|
|
# not cached
|
|
|
|
Post.find(1, 2, 3)
|
|
|
|
Post.find([1,2])
|
2014-09-16 14:23:02 -04:00
|
|
|
```
|
|
|
|
|
2014-11-03 08:38:04 -05:00
|
|
|
- `find_by` with SQL fragments:
|
2014-09-16 14:23:02 -04:00
|
|
|
|
|
|
|
```ruby
|
2014-11-26 19:20:57 -05:00
|
|
|
Post.find_by('published_at < ?', 2.weeks.ago)
|
2014-09-16 14:23:02 -04:00
|
|
|
```
|
2014-08-19 21:39:41 -04:00
|
|
|
|
|
|
|
### Web Console
|
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
New applications generated with Rails 4.2 now come with the [Web
|
2014-11-27 17:54:09 -05:00
|
|
|
Console](https://github.com/rails/web-console) gem by default. Web Console adds
|
|
|
|
an interactive Ruby console on every error page and provides a `console` view
|
|
|
|
and controller helpers.
|
2014-08-19 21:39:41 -04:00
|
|
|
|
2014-11-27 17:54:09 -05:00
|
|
|
The interactive console on error pages lets you execute code in the context of
|
|
|
|
the place where the exception originated. The `console` helper, if called
|
|
|
|
anywhere in a view or controller, launches an interactive console with the final
|
|
|
|
context, once rendering has completed.
|
2014-08-19 21:39:41 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
### Foreign Key Support
|
2014-06-12 02:42:00 -04:00
|
|
|
|
|
|
|
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.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
|
2014-09-02 14:16:28 -04:00
|
|
|
Incompatibilities
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
Previously deprecated functionality has been removed. Please refer to the
|
|
|
|
individual components for new deprecations in this release.
|
|
|
|
|
|
|
|
The following changes may require immediate action upon upgrade.
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
### `render` with a String Argument
|
2014-09-25 11:07:07 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
Previously, calling `render "foo/bar"` in a controller action was equivalent to
|
2014-11-28 08:18:44 -05:00
|
|
|
`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean
|
|
|
|
`render template: "foo/bar"` instead. If you need to render a file, please
|
|
|
|
change your code to use the explicit form (`render file: "foo/bar"`) instead.
|
2014-09-25 11:07:07 -04:00
|
|
|
|
2014-11-27 17:54:09 -05:00
|
|
|
### `respond_with` / Class-Level `respond_to`
|
2014-09-02 14:16:28 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
`respond_with` and the corresponding class-level `respond_to` have been moved
|
|
|
|
to the [responders](https://github.com/plataformatec/responders) gem. Add
|
|
|
|
`gem 'responders', '~> 2.0'` to your Gemfile to use it:
|
2014-09-02 14:16:28 -04:00
|
|
|
|
|
|
|
```ruby
|
|
|
|
# app/controllers/users_controller.rb
|
|
|
|
|
|
|
|
class UsersController < ApplicationController
|
|
|
|
respond_to :html, :json
|
|
|
|
|
|
|
|
def show
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
respond_with @user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
Instance-level `respond_to` is unaffected:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# app/controllers/users_controller.rb
|
|
|
|
|
|
|
|
class UsersController < ApplicationController
|
|
|
|
def show
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json { render json: @user }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
### Default Host for `rails server`
|
2014-09-20 05:44:36 -04:00
|
|
|
|
|
|
|
Due to a [change in Rack](https://github.com/rack/rack/commit/28b014484a8ac0bbb388e7eaeeef159598ec64fc),
|
|
|
|
`rails server` now listens on `localhost` instead of `0.0.0.0` by default. This
|
2014-11-28 08:18:44 -05:00
|
|
|
should have minimal impact on the standard development workflow as both
|
|
|
|
http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before
|
|
|
|
on your own machine.
|
2014-09-20 05:44:36 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
However, with this change you will no longer be able to access the Rails
|
|
|
|
server from a different machine, for example if your development environment
|
|
|
|
is in a virtual machine and you would like to access it from the host machine.
|
|
|
|
In such cases, please start the server with `rails server -b 0.0.0.0` to
|
|
|
|
restore the old behavior.
|
2014-09-20 05:44:36 -04:00
|
|
|
|
|
|
|
If you do this, be sure to configure your firewall properly such that only
|
|
|
|
trusted machines on your network can access your development server.
|
|
|
|
|
2014-09-02 14:16:28 -04:00
|
|
|
### HTML Sanitizer
|
|
|
|
|
|
|
|
The HTML sanitizer has been replaced with a new, more robust, implementation
|
2014-11-26 19:20:57 -05:00
|
|
|
built upon [Loofah](https://github.com/flavorjones/loofah) and
|
|
|
|
[Nokogiri](https://github.com/sparklemotion/nokogiri). The new sanitizer is
|
|
|
|
more secure and its sanitization is more powerful and flexible.
|
2014-09-02 14:16:28 -04:00
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
Due to the new algorithm, the sanitized output may be different for certain
|
|
|
|
pathological inputs.
|
2014-09-02 14:16:28 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
If you have a particular need for the exact output of the old sanitizer, you
|
|
|
|
can add the [rails-deprecated_sanitizer](https://github.com/kaspth/rails-deprecated_sanitizer)
|
|
|
|
gem to the `Gemfile`, to have the old behavior. The gem does not issue
|
|
|
|
deprecation warnings because it is opt-in.
|
2014-09-02 14:16:28 -04:00
|
|
|
|
|
|
|
`rails-deprecated_sanitizer` will be supported for Rails 4.2 only; it will not
|
|
|
|
be maintained for Rails 5.0.
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
See [this blog post](http://blog.plataformatec.com.br/2014/07/the-new-html-sanitizer-in-rails-4-2/)
|
|
|
|
for more details on the changes in the new sanitizer.
|
2014-09-02 14:16:28 -04:00
|
|
|
|
|
|
|
### `assert_select`
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
`assert_select` is now based on [Nokogiri](https://github.com/sparklemotion/nokogiri).
|
|
|
|
As a result, some previously-valid selectors are now unsupported. If your
|
|
|
|
application is using any of these spellings, you will need to update them:
|
2014-09-02 14:16:28 -04:00
|
|
|
|
|
|
|
* Values in attribute selectors may need to be quoted if they contain
|
|
|
|
non-alphanumeric characters.
|
|
|
|
|
|
|
|
```
|
2014-11-27 17:54:09 -05:00
|
|
|
# before
|
|
|
|
a[href=/]
|
|
|
|
a[href$=/]
|
|
|
|
|
|
|
|
# now
|
|
|
|
a[href="/"]
|
|
|
|
a[href$="/"]
|
2014-09-02 14:16:28 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
* DOMs built from HTML source containing invalid HTML with improperly
|
|
|
|
nested elements may differ.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
``` ruby
|
|
|
|
# content: <div><i><p></i></div>
|
|
|
|
|
|
|
|
# before:
|
|
|
|
assert_select('div > i') # => true
|
|
|
|
assert_select('div > p') # => false
|
|
|
|
assert_select('i > p') # => true
|
|
|
|
|
|
|
|
# now:
|
|
|
|
assert_select('div > i') # => true
|
|
|
|
assert_select('div > p') # => true
|
|
|
|
assert_select('i > p') # => false
|
|
|
|
```
|
|
|
|
|
|
|
|
* If the data selected contains entities, the value selected for comparison
|
|
|
|
used to be raw (e.g. `AT&T`), and now is evaluated
|
|
|
|
(e.g. `AT&T`).
|
|
|
|
|
|
|
|
``` ruby
|
|
|
|
# content: <p>AT&T</p>
|
|
|
|
|
|
|
|
# before:
|
|
|
|
assert_select('p', 'AT&T') # => true
|
|
|
|
assert_select('p', 'AT&T') # => false
|
|
|
|
|
|
|
|
# now:
|
|
|
|
assert_select('p', 'AT&T') # => true
|
|
|
|
assert_select('p', 'AT&T') # => false
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
Railties
|
|
|
|
--------
|
|
|
|
|
2014-07-06 00:15:33 -04:00
|
|
|
Please refer to the [Changelog][railties] for detailed changes.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
### Removals
|
|
|
|
|
2014-11-06 06:16:11 -05:00
|
|
|
* The `--skip-action-view` option has been removed from the
|
|
|
|
app generator. ([Pull Request](https://github.com/rails/rails/pull/17042))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* The `rails application` command has been removed without replacement.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/11616))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-11 05:15:00 -04:00
|
|
|
### Deprecations
|
|
|
|
|
2014-11-24 22:25:50 -05:00
|
|
|
* Deprecated missing `config.log_level` for production environments.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16622))
|
|
|
|
|
2014-11-25 07:07:08 -05:00
|
|
|
* Deprecated `rake test:all` in favor of `rake test` as it now run all tests
|
|
|
|
in the `test` folder.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/17348))
|
|
|
|
|
|
|
|
* Deprecated `rake test:all:db` in favor of `rake test:db`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/17348))
|
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Deprecated `Rails::Rack::LogTailer` without replacement.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/84a13e019e93efaa8994b3f8303d635a7702dbce))
|
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
### Notable changes
|
|
|
|
|
2014-08-19 12:41:48 -04:00
|
|
|
* Introduced `web-console` in the default application Gemfile.
|
2014-08-27 04:23:53 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/11667))
|
2014-08-19 12:41:48 -04:00
|
|
|
|
2014-08-18 12:46:28 -04:00
|
|
|
* Added a `required` option to the model generator for associations.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16062))
|
|
|
|
|
2014-08-19 18:41:15 -04:00
|
|
|
* Introduced the `x` namespace for defining custom configuration options:
|
2014-08-18 12:46:28 -04:00
|
|
|
|
2014-08-18 13:07:56 -04:00
|
|
|
```ruby
|
|
|
|
# config/environments/production.rb
|
2014-08-19 18:41:15 -04:00
|
|
|
config.x.payment_processing.schedule = :daily
|
|
|
|
config.x.payment_processing.retries = 3
|
2014-08-19 19:07:39 -04:00
|
|
|
config.x.super_debugger = true
|
2014-08-18 13:07:56 -04:00
|
|
|
```
|
2014-08-18 12:46:28 -04:00
|
|
|
|
|
|
|
These options are then available through the configuration object:
|
|
|
|
|
2014-08-18 13:07:56 -04:00
|
|
|
```ruby
|
2014-08-19 18:41:15 -04:00
|
|
|
Rails.configuration.x.payment_processing.schedule # => :daily
|
|
|
|
Rails.configuration.x.payment_processing.retries # => 3
|
|
|
|
Rails.configuration.x.super_debugger # => true
|
2014-08-18 13:07:56 -04:00
|
|
|
```
|
2014-08-18 12:46:28 -04:00
|
|
|
|
|
|
|
([Commit](https://github.com/rails/rails/commit/611849772dd66c2e4d005dcfe153f7ce79a8a7db))
|
|
|
|
|
|
|
|
* Introduced `Rails::Application.config_for` to load a configuration for the
|
|
|
|
current environment.
|
|
|
|
|
2014-08-18 13:07:56 -04:00
|
|
|
```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
|
2014-09-19 13:30:31 -04:00
|
|
|
Rails.application.configure do
|
2014-08-18 13:07:56 -04:00
|
|
|
config.middleware.use ExceptionNotifier, config_for(:exception_notification)
|
|
|
|
end
|
|
|
|
```
|
2014-08-18 12:46:28 -04:00
|
|
|
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16129))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Introduced a `--skip-turbolinks` option in the app generator to not generate
|
|
|
|
turbolinks integration.
|
2014-11-05 05:36:08 -05:00
|
|
|
([Commit](https://github.com/rails/rails/commit/bf17c8a531bc8059d50ad731398002a3e7162a7d))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Introduced a `bin/setup` script as a convention for automated setup code when
|
2014-08-19 04:22:43 -04:00
|
|
|
bootstrapping an application.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15189))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Changed the default value for `config.assets.digest` to `true` in development.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15155))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Introduced an API to register new extensions for `rake notes`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14379))
|
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Introduced an `after_bundle` callback for use in Rails templates.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16359))
|
|
|
|
|
2014-08-25 16:58:05 -04:00
|
|
|
* Introduced `Rails.gem_version` as a convenience method to return
|
|
|
|
`Gem::Version.new(Rails.version)`.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14101))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
Action Pack
|
|
|
|
-----------
|
|
|
|
|
2014-07-06 00:15:33 -04:00
|
|
|
Please refer to the [Changelog][action-pack] for detailed changes.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-14 03:35:32 -04:00
|
|
|
### Removals
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* `respond_with` and the class-level `respond_to` have been removed from Rails and
|
2014-08-19 04:22:43 -04:00
|
|
|
moved to the `responders` gem (version 2.0). Add `gem 'responders', '~> 2.0'`
|
|
|
|
to your `Gemfile` to continue using these features.
|
2014-11-25 07:30:15 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16526),
|
|
|
|
[More Details](http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#responders))
|
2014-08-18 13:06:00 -04:00
|
|
|
|
2014-08-14 03:35:32 -04:00
|
|
|
* Removed deprecated `AbstractController::Helpers::ClassMethods::MissingHelperError`
|
|
|
|
in favor of `AbstractController::Helpers::MissingHelperError`.
|
2014-08-14 04:00:22 -04:00
|
|
|
([Commit](https://github.com/rails/rails/commit/a1ddde15ae0d612ff2973de9cf768ed701b594e8))
|
2014-08-14 03:35:32 -04:00
|
|
|
|
2014-06-06 21:44:30 -04:00
|
|
|
### Deprecations
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-10-28 12:48:01 -04:00
|
|
|
* Deprecated the `only_path` option on `*_path` helpers.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/aa1fadd48fb40dd9396a383696134a259aa59db9))
|
|
|
|
|
2014-08-19 00:36:45 -04:00
|
|
|
* 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))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Deprecated support for setting the `:to` option of a router to a symbol or a
|
2014-11-26 19:20:57 -05:00
|
|
|
string that does not contain a "#" character:
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-09 04:21:23 -04:00
|
|
|
```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))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Deprecated support for string keys in URL helpers:
|
2014-11-24 22:42:58 -05:00
|
|
|
|
|
|
|
```ruby
|
|
|
|
# bad
|
2014-11-26 19:20:57 -05:00
|
|
|
root_path('controller' => 'posts', 'action' => 'index')
|
|
|
|
|
2014-11-24 22:42:58 -05:00
|
|
|
# good
|
2014-11-26 19:20:57 -05:00
|
|
|
root_path(controller: 'posts', action: 'index')
|
2014-11-24 22:42:58 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/17743))
|
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
### Notable changes
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* The `*_filter` family of methods have been removed from the documentation. Their
|
|
|
|
usage is discouraged in favor of the `*_action` family of methods:
|
2014-07-09 04:21:23 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
2014-08-26 16:28:54 -04:00
|
|
|
If your application currently depends on these methods, you should use the
|
2014-07-09 04:21:23 -04:00
|
|
|
replacement `*_action` methods instead. These methods will be deprecated in
|
2014-08-26 16:28:54 -04:00
|
|
|
the future and will eventually be removed from Rails.
|
2014-07-09 04:21:23 -04:00
|
|
|
|
|
|
|
(Commit [1](https://github.com/rails/rails/commit/6c5f43bab8206747a8591435b2aa0ff7051ad3de),
|
|
|
|
[2](https://github.com/rails/rails/commit/489a8f2a44dc9cea09154ee1ee2557d1f037c7d4))
|
2014-07-09 03:12:51 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* `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))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Rails now automatically includes the template's digest in ETags.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16527))
|
|
|
|
|
|
|
|
* Segments that are passed into URL helpers are now automatically escaped.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/5460591f0226a9d248b7b4f89186bd5553e7768f))
|
|
|
|
|
|
|
|
* 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))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Added the HTTP method `MKCALENDAR` from [RFC 4791](https://tools.ietf.org/html/rfc4791).
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15121))
|
2014-07-09 03:12:51 -04:00
|
|
|
|
2014-08-25 16:58:05 -04:00
|
|
|
* `*_fragment.action_controller` notifications now include the controller
|
|
|
|
and action name in the payload.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14137))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-19 04:22:43 -04:00
|
|
|
* Improved the Routing Error page with fuzzy matching for route search.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14619))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-19 04:22:43 -04:00
|
|
|
* Added an option to disable logging of CSRF failures.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14280))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-21 12:52:25 -04:00
|
|
|
* When the Rails server is set to serve static assets, gzip assets will now be
|
2014-11-03 08:38:04 -05:00
|
|
|
served if the client supports it and a pre-generated gzip file (`.gz`) is on disk.
|
2014-08-21 12:52:25 -04:00
|
|
|
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))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-12-16 04:43:33 -05:00
|
|
|
* When calling the `process` helpers in an integration test the path needs to have
|
|
|
|
a leading slash. Previously you could omit it but that was a byproduct of the
|
|
|
|
implementation and not an intentional feature, e.g.:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
test "list all posts" do
|
|
|
|
get "/posts"
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2014-06-25 13:39:19 -04:00
|
|
|
Action View
|
2014-11-26 19:20:57 -05:00
|
|
|
-----------
|
2014-06-25 13:39:19 -04:00
|
|
|
|
2014-07-06 00:15:33 -04:00
|
|
|
Please refer to the [Changelog][action-view] for detailed changes.
|
2014-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
### Deprecations
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* 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))
|
2014-06-25 13:39:19 -04:00
|
|
|
|
2014-08-19 04:22:43 -04:00
|
|
|
* Deprecated `ActionView::Digestor#digest(name, format, finder, options = {})`.
|
|
|
|
Arguments should be passed as a hash instead.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14243))
|
2014-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
### Notable changes
|
|
|
|
|
2014-09-25 11:07:07 -04:00
|
|
|
* `render "foo/bar"` now expands to `render template: "foo/bar"` instead of
|
|
|
|
`render file: "foo/bar"`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16888))
|
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* 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))
|
|
|
|
|
2014-08-19 00:50:59 -04:00
|
|
|
* Introduced a `#{partial_name}_iteration` special local variable for use with
|
2014-08-19 04:22:43 -04:00
|
|
|
partials that are rendered with a collection. It provides access to the
|
2014-11-26 19:20:57 -05:00
|
|
|
current state of the iteration via the `index`, `size`, `first?` and
|
|
|
|
`last?` methods.
|
2014-08-19 00:50:59 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/7698))
|
|
|
|
|
2014-08-21 15:57:19 -04:00
|
|
|
* Placeholder I18n follows the same convention as `label` I18n.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16438))
|
|
|
|
|
2014-06-25 13:39:19 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
Action Mailer
|
|
|
|
-------------
|
|
|
|
|
2014-07-06 00:15:33 -04:00
|
|
|
Please refer to the [Changelog][action-mailer] for detailed changes.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-19 01:22:46 -04:00
|
|
|
### Deprecations
|
|
|
|
|
|
|
|
* Deprecated `*_path` helpers in mailers. Always use `*_url` helpers instead.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15840))
|
|
|
|
|
2014-11-03 08:38:04 -05:00
|
|
|
* Deprecated `deliver` / `deliver!` in favor of `deliver_now` / `deliver_now!`.
|
2014-08-20 08:34:37 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16582))
|
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
### Notable changes
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* `link_to` and `url_for` generate absolute URLs by default in templates,
|
|
|
|
it is no longer needed to pass `only_path: false`.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/9685080a7677abfa5d288a81c3e078368c6bb67c))
|
|
|
|
|
2014-08-19 01:22:46 -04:00
|
|
|
* Introduced `deliver_later` which enqueues a job on the application's queue
|
2014-08-25 16:58:05 -04:00
|
|
|
to deliver emails asynchronously.
|
2014-08-19 01:22:46 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16485))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Added the `show_previews` configuration option for enabling mailer previews
|
|
|
|
outside of the development environment.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15970))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
Active Record
|
|
|
|
-------------
|
|
|
|
|
2014-08-25 16:58:05 -04:00
|
|
|
Please refer to the [Changelog][active-record] for detailed changes.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-06-25 12:43:32 -04:00
|
|
|
### Removals
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Removed `cache_attributes` and friends. All attributes are cached.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15429))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Removed deprecated method `ActiveRecord::Base.quoted_locking_column`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15612))
|
2014-06-25 12:43:32 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* 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))
|
2014-06-25 12:43:32 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Removed unused `:timestamp` type. Transparently alias it to `:datetime`
|
|
|
|
in all cases. Fixes inconsistencies when column types are sent outside of
|
2014-11-26 19:20:57 -05:00
|
|
|
Active Record, such as for XML serialization.
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15184))
|
2014-06-25 12:43:32 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
### Deprecations
|
|
|
|
|
2014-08-19 21:20:05 -04:00
|
|
|
* Deprecated swallowing of errors inside `after_commit` and `after_rollback`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16537))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* 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))
|
2014-06-25 12:43:32 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Deprecated passing Active Record objects to `.find` or `.exists?`. Call
|
2014-11-26 19:20:57 -05:00
|
|
|
`id` on the objects first.
|
2014-07-13 20:23:32 -04:00
|
|
|
(Commit [1](https://github.com/rails/rails/commit/d92ae6ccca3bcfd73546d612efaea011270bd270),
|
|
|
|
[2](https://github.com/rails/rails/commit/d35f0033c7dec2b8d8b52058fb8db495d49596f7))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Deprecated half-baked support for PostgreSQL range values with excluding
|
|
|
|
beginnings. We currently map PostgreSQL ranges to Ruby ranges. This conversion
|
2014-11-26 19:20:57 -05:00
|
|
|
is not fully possible because Ruby ranges do not support excluded beginnings.
|
2014-07-09 04:21:23 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
The current solution of incrementing the beginning is not correct
|
|
|
|
and is now deprecated. For subtypes where we don't know how to increment
|
2014-11-26 19:20:57 -05:00
|
|
|
(e.g. `succ` is not defined) it will raise an `ArgumentError` for ranges
|
2014-07-13 20:23:32 -04:00
|
|
|
with excluding beginnings.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/91949e48cf41af9f3e4ffba3e5eecf9b0a08bfc3))
|
2014-06-15 11:19:54 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Deprecated calling `DatabaseTasks.load_schema` without a connection. Use
|
|
|
|
`DatabaseTasks.load_schema_current` instead.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/f15cef67f75e4b52fd45655d7c6ab6b35623c608))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Deprecated `sanitize_sql_hash_for_conditions` without replacement. Using a
|
2014-11-26 19:20:57 -05:00
|
|
|
`Relation` for performing queries and updates is the preferred API.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Commit](https://github.com/rails/rails/commit/d5902c9e))
|
2014-11-24 13:42:30 -05:00
|
|
|
|
2014-12-16 04:35:29 -05:00
|
|
|
* Deprecated `add_timestamps` and `t.timestamps` without passing the `:null`
|
|
|
|
option. The default of `null: true` will change in Rails 5 to `null: false`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16481))
|
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Deprecated `Reflection#source_macro` without replacement as it is no longer
|
|
|
|
needed in Active Record.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16373))
|
2014-08-19 21:20:05 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Deprecated `serialized_attributes` without replacement.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15704))
|
2014-08-19 21:20:05 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* 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))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Deprecated using `.joins`, `.preload` and `.eager_load` with associations
|
2014-11-26 19:20:57 -05:00
|
|
|
that depend on the instance state (i.e. those defined with a scope that
|
2014-11-25 07:56:00 -05:00
|
|
|
takes an argument) without replacement.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/ed56e596a0467390011bc9d56d462539776adac1))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
### Notable changes
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-12-18 04:07:23 -05:00
|
|
|
* `SchemaDumper` uses `force: :cascade` on `create_table`. This makes it
|
|
|
|
possible to reload a schema when foreign keys are in place.
|
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* Added a `:required` option to singular associations, which defines a
|
|
|
|
presence validation on the association.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16056))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* `ActiveRecord::Dirty` now detects in-place changes to mutable values.
|
2014-11-26 19:20:57 -05:00
|
|
|
Serialized attributes on Active Record models are no longer saved when
|
2014-07-13 20:23:32 -04:00
|
|
|
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))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Introduced the `db:purge` Rake task to empty the database for the
|
2014-11-25 07:56:00 -05:00
|
|
|
current environment.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/e2f232aba15937a4b9d14bd91e0392c6d55be58d))
|
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
* Introduced `ActiveRecord::Base#validate!` that raises
|
|
|
|
`ActiveRecord::RecordInvalid` if the record is invalid.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/8639))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Introduced `validate` as an alias for `valid?`.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14456))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* `touch` now accepts multiple attributes to be touched at once.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14423))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* The PostgreSQL adapter now supports the `jsonb` datatype in PostgreSQL 9.4+.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16220))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* The PostgreSQL and SQLite adapters no longer add a default limit of 255
|
2014-07-13 20:23:32 -04:00
|
|
|
characters on string columns.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14579))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Added support for the `citext` column type in the PostgreSQL adapter.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/12523))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Added support for user-created range types in the PostgreSQL adapter.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Commit](https://github.com/rails/rails/commit/4cb47167e747e8f9dc12b0ddaf82bdb68c03e032))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* `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
|
2014-11-26 19:20:57 -05:00
|
|
|
`some/path`. This behavior was deprecated on Rails 4.1).
|
2014-07-13 20:23:32 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14569))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* 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))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Added `ActiveRecord::Base#pretty_print` to pretty print models.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15172))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-25 07:56:00 -05:00
|
|
|
* `ActiveRecord::Base#reload` now behaves the same as `m = Model.find(m.id)`,
|
|
|
|
meaning that it no longer retains the extra attributes from custom
|
2014-11-26 19:20:57 -05:00
|
|
|
`SELECT`s.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15866))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-11-28 08:18:44 -05:00
|
|
|
* `ActiveRecord::Base#reflections` now returns a hash with string keys instead
|
|
|
|
of symbol keys. ([Pull Request](https://github.com/rails/rails/pull/17718))
|
2014-11-25 07:56:00 -05:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* The `references` method in migrations now supports a `type` option for
|
2014-11-25 07:56:00 -05:00
|
|
|
specifying the type of the foreign key (e.g. `:uuid`).
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16231))
|
2014-07-04 20:47:00 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
Active Model
|
|
|
|
------------
|
|
|
|
|
2014-07-06 00:15:33 -04:00
|
|
|
Please refer to the [Changelog][active-model] for detailed changes.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-06-25 13:39:19 -04:00
|
|
|
### Removals
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Removed deprecated `Validator#setup` without replacement.
|
2014-08-19 20:44:08 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/10716))
|
|
|
|
|
|
|
|
### Deprecations
|
|
|
|
|
2014-08-25 16:58:05 -04:00
|
|
|
* Deprecated `reset_#{attribute}` in favor of `restore_#{attribute}`.
|
2014-08-19 20:44:08 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16180))
|
|
|
|
|
2014-08-25 16:58:05 -04:00
|
|
|
* Deprecated `ActiveModel::Dirty#reset_changes` in favor of
|
2014-11-26 19:20:57 -05:00
|
|
|
`clear_changes_information`.
|
2014-08-19 20:44:08 -04:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16180))
|
2014-06-25 13:39:19 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
### Notable changes
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Introduced `validate` as an alias for `valid?`.
|
2014-11-25 07:56:00 -05:00
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14456))
|
|
|
|
|
2014-08-19 20:44:08 -04:00
|
|
|
* Introduced the `restore_attributes` method in `ActiveModel::Dirty` to restore
|
|
|
|
the changed (dirty) attributes to their previous values.
|
2014-08-25 16:58:05 -04:00
|
|
|
(Pull Request [1](https://github.com/rails/rails/pull/14861),
|
|
|
|
[2](https://github.com/rails/rails/pull/16180))
|
2014-08-19 20:44:08 -04:00
|
|
|
|
2014-09-24 16:38:51 -04:00
|
|
|
* `has_secure_password` no longer disallows blank passwords (i.e. passwords
|
2014-08-19 20:44:08 -04:00
|
|
|
that contains only spaces) by default.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/16412))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* `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))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
Active Support
|
|
|
|
--------------
|
|
|
|
|
2014-07-06 00:15:33 -04:00
|
|
|
Please refer to the [Changelog][active-support] for detailed changes.
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
### Removals
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Removed deprecated `Numeric#ago`, `Numeric#until`, `Numeric#since`,
|
|
|
|
`Numeric#from_now`.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/f1eddea1e3f6faf93581c43651348f48b2b7d8bb))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Removed deprecated string based terminators for `ActiveSupport::Callbacks`.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/15100))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
### Deprecations
|
|
|
|
|
2014-08-19 21:01:19 -04:00
|
|
|
* Deprecated `Kernel#silence_stderr`, `Kernel#capture` and `Kernel#quietly`
|
|
|
|
without replacement.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/13392))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Deprecated `Class#superclass_delegating_accessor`, use
|
|
|
|
`Class#class_attribute` instead.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14271))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* Deprecated `ActiveSupport::SafeBuffer#prepend!` as
|
|
|
|
`ActiveSupport::SafeBuffer#prepend` now performs the same function.
|
|
|
|
([Pull Request](https://github.com/rails/rails/pull/14529))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
|
|
|
### Notable changes
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* Introduced a new configuration option `active_support.test_order` for
|
2014-09-08 08:32:16 -04:00
|
|
|
specifying the order test cases are executed. This option currently defaults
|
|
|
|
to `:sorted` but will be changed to `:random` in Rails 5.0.
|
2014-09-26 13:10:06 -04:00
|
|
|
([Commit](https://github.com/rails/rails/commit/53e877f7d9291b2bf0b8c425f9e32ef35829f35b))
|
2014-09-08 08:32:16 -04:00
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* `Object#try` and `Object#try!` can now be used without an explicit receiver in the block.
|
2014-11-06 06:16:11 -05:00
|
|
|
([Commit](https://github.com/rails/rails/commit/5e51bdda59c9ba8e5faf86294e3e431bd45f1830),
|
|
|
|
[Pull Request](https://github.com/rails/rails/pull/17361))
|
|
|
|
|
2014-08-19 21:01:19 -04:00
|
|
|
* The `travel_to` test helper now truncates the `usec` component to 0.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/9f6e82ee4783e491c20f5244a613fdeb4024beb5))
|
|
|
|
|
|
|
|
* Introduced `Object#itself` as an identity function.
|
|
|
|
(Commit [1](https://github.com/rails/rails/commit/702ad710b57bef45b081ebf42e6fa70820fdd810),
|
|
|
|
[2](https://github.com/rails/rails/commit/64d91122222c11ad3918cc8e2e3ebc4b0a03448a))
|
|
|
|
|
2014-11-26 19:20:57 -05:00
|
|
|
* `Object#with_options` can now be used without an explicit receiver in the block.
|
2014-08-19 21:01:19 -04:00
|
|
|
([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))
|
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* 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))
|
2014-07-11 05:15:00 -04:00
|
|
|
|
2014-07-13 20:23:32 -04:00
|
|
|
* The `humanize` inflector helper now strips any leading underscores.
|
|
|
|
([Commit](https://github.com/rails/rails/commit/daaa21bc7d20f2e4ff451637423a25ff2d5e75c7))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-08-19 04:22:43 -04:00
|
|
|
* Introduced `Concern#class_methods` as an alternative to
|
2014-07-13 20:23:32 -04:00
|
|
|
`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))
|
2014-05-24 17:03:53 -04:00
|
|
|
|
2014-12-16 04:43:33 -05:00
|
|
|
* New [guide](constant_autoloading_and_reloading.html) about constant autoloading and reloading.
|
2014-07-04 20:54:33 -04:00
|
|
|
|
2014-05-24 17:03:53 -04:00
|
|
|
Credits
|
|
|
|
-------
|
|
|
|
|
|
|
|
See the
|
|
|
|
[full list of contributors to Rails](http://contributors.rubyonrails.org/) for
|
2014-07-13 20:23:32 -04:00
|
|
|
the many people who spent many hours making Rails the stable and robust
|
|
|
|
framework it is today. Kudos to all of them.
|
2014-07-06 00:15:33 -04:00
|
|
|
|
|
|
|
[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
|