2020-05-04 23:57:39 -04:00
**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON https://guides.rubyonrails.org.**
Ruby on Rails 6.1 Release Notes
===============================
Highlights in Rails 6.1:
2020-10-29 21:25:03 -04:00
* Per-database Connection Switching
* Horizontal Sharding
* Strict Loading Associations
* Delegated Types
* Destroy Associations Async
2020-05-04 23:57:39 -04:00
These release notes cover only the major changes. To learn about various bug
2021-05-31 06:11:28 -04:00
fixes and changes, please refer to the changelogs or check out the [list of
2021-01-19 15:43:24 -05:00
commits](https://github.com/rails/rails/commits/6-1-stable) in the main Rails
2020-05-04 23:57:39 -04:00
repository on GitHub.
--------------------------------------------------------------------------------
Upgrading to Rails 6.1
----------------------
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 6.0 in case you
haven't and make sure your application still runs as expected before attempting
an update to Rails 6.1. A list of things to watch out for when upgrading is
available in the
[Upgrading Ruby on Rails ](upgrading_ruby_on_rails.html#upgrading-from-rails-6-0-to-rails-6-1 )
guide.
Major Features
--------------
2020-10-29 21:25:03 -04:00
### Per-database Connection Switching
Rails 6.1 provides you with the ability to [switch connections per-database ](https://github.com/rails/rails/pull/40370 ). In 6.0 if you switched to the `reading` role then all database connections also switched to the reading role. Now in 6.1 if you set `legacy_connection_handling` to `false` in your configuration, Rails will allow you to switch connections for a single database by calling `connected_to` on the corresponding abstract class.
### Horizontal Sharding
2020-11-08 22:35:04 -05:00
Rails 6.0 provided the ability to functionally partition (multiple partitions, different schemas) your database but wasn't able to support horizontal sharding (same schema, multiple partitions). Rails wasn't able to support horizontal sharding because models in Active Record could only have one connection per-role per-class. This is now fixed and [horizontal sharding ](https://github.com/rails/rails/pull/38531 ) with Rails is available.
2020-10-29 21:25:03 -04:00
### Strict Loading Associations
[Strict loading associations ](https://github.com/rails/rails/pull/37400 ) allows you to ensure that all
your associations are loaded eagerly and stop N+1's before they happen.
### Delegated Types
2021-05-31 06:11:28 -04:00
[Delegated Types ](https://github.com/rails/rails/pull/39341 ) is an alternative to single-table inheritance. This helps represent class hierarchies allowing the superclass to be a concrete class that is represented by its own table. Each subclass has its own table for additional attributes.
2020-10-29 21:25:03 -04:00
### Destroy Associations Async
[Destroy associations async ](https://github.com/rails/rails/pull/40157 ) adds the ability for applications to `destroy` associations in a background job. This can help you avoid timeouts and other performance issues in your application when destroying data.
2020-05-04 23:57:39 -04:00
Railties
--------
Please refer to the [Changelog][railties] for detailed changes.
### Removals
2020-10-29 14:22:16 -04:00
* Remove deprecated `rake notes` tasks.
* Remove deprecated `connection` option in the `rails dbconsole` command.
2020-10-29 13:50:03 -04:00
2020-10-29 15:09:19 -04:00
* Remove deprecated `SOURCE_ANNOTATION_DIRECTORIES` environment variable support from `rails notes` .
2020-10-29 16:05:22 -04:00
* Remove deprecated `server` argument from the rails server command.
2020-10-29 16:41:13 -04:00
* Remove deprecated support for using the `HOST` environment variable to specify the server IP.
2020-10-29 17:17:17 -04:00
* Remove deprecated `rake dev:cache` tasks.
2020-10-29 17:18:29 -04:00
* Remove deprecated `rake routes` tasks.
2020-10-29 17:18:44 -04:00
* Remove deprecated `rake initializers` tasks.
2020-05-04 23:57:39 -04:00
### Deprecations
### Notable changes
Action Cable
------------
Please refer to the [Changelog][action-cable] for detailed changes.
### Removals
### Deprecations
### Notable changes
Action Pack
-----------
Please refer to the [Changelog][action-pack] for detailed changes.
### Removals
2020-05-06 20:44:44 -04:00
* Remove deprecated `ActionDispatch::Http::ParameterFilter` .
* Remove deprecated `force_ssl` at the controller level.
### Deprecations
2020-10-28 15:09:38 -04:00
* Deprecate `config.action_dispatch.return_only_media_type_on_content_type` .
2020-05-06 20:44:44 -04:00
### Notable changes
2020-10-28 15:09:38 -04:00
* Change `ActionDispatch::Response#content_type` to return the full Content-Type header.
2020-05-06 20:44:44 -04:00
Action View
-----------
Please refer to the [Changelog][action-view] for detailed changes.
### Removals
2020-05-06 20:19:54 -04:00
* Remove deprecated `escape_whitelist` from `ActionView::Template::Handlers::ERB` .
2020-05-06 18:21:19 -04:00
* Remove deprecated `find_all_anywhere` from `ActionView::Resolver` .
2020-05-06 18:18:01 -04:00
* Remove deprecated `formats` from `ActionView::Template::HTML` .
2020-05-06 18:16:38 -04:00
* Remove deprecated `formats` from `ActionView::Template::RawFile` .
2020-05-06 18:15:09 -04:00
* Remove deprecated `formats` from `ActionView::Template::Text` .
2020-05-06 18:10:28 -04:00
* Remove deprecated `find_file` from `ActionView::PathSet` .
2020-05-06 17:57:29 -04:00
* Remove deprecated `rendered_format` from `ActionView::LookupContext` .
2020-05-06 17:53:39 -04:00
* Remove deprecated `find_file` from `ActionView::ViewPaths` .
2020-05-06 16:28:34 -04:00
* Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
in `ActionView::Base#initialize` .
2020-05-06 13:21:07 -04:00
* Remove deprecated `format` argument `ActionView::Base#initialize` .
2020-05-05 19:33:47 -04:00
* Remove deprecated `ActionView::Template#refresh` .
2020-05-05 19:32:32 -04:00
* Remove deprecated `ActionView::Template#original_encoding` .
2020-05-05 19:31:11 -04:00
* Remove deprecated `ActionView::Template#variants` .
2020-05-05 19:29:59 -04:00
* Remove deprecated `ActionView::Template#formats` .
2020-05-05 19:27:21 -04:00
* Remove deprecated `ActionView::Template#virtual_path=` .
2020-05-05 19:23:24 -04:00
* Remove deprecated `ActionView::Template#updated_at` .
* Remove deprecated `updated_at` argument required on `ActionView::Template#initialize` .
2020-05-05 17:29:27 -04:00
* Remove deprecated `ActionView::Template.finalize_compiled_template_methods` .
* Remove deprecated `config.action_view.finalize_compiled_template_methods`
2020-05-05 16:37:29 -04:00
* Remove deprecated support to calling `ActionView::ViewPaths#with_fallback` with a block.
2020-05-05 16:13:01 -04:00
* Remove deprecated support to passing absolute paths to `render template:` .
2020-05-05 15:58:55 -04:00
* Remove deprecated support to passing relative paths to `render file:` .
2020-05-05 11:20:48 -04:00
* Remove support to template handlers that don't accept two arguments.
2020-05-05 01:45:21 -04:00
* Remove deprecated pattern argument in `ActionView::Template::PathResolver` .
2020-05-05 01:28:48 -04:00
* Remove deprecated support to call private methods from object in some view helpers.
2020-05-04 23:57:39 -04:00
### Deprecations
### Notable changes
2020-10-29 21:36:25 -04:00
* Require that `ActionView::Base` subclasses implement `#compiled_method_container` .
* Make `locals` argument required on `ActionView::Template#initialize` .
2020-12-18 14:11:16 -05:00
* The `javascript_include_tag` and `stylesheet_link_tag` asset helpers generate a `Link` header that gives hints to modern browsers about preloading assets. This can be disabled by setting `config.action_view.preload_links_header` to `false` .
2020-05-04 23:57:39 -04:00
Action Mailer
-------------
Please refer to the [Changelog][action-mailer] for detailed changes.
### Removals
2021-01-19 15:43:24 -05:00
* Remove deprecated `ActionMailer::Base.receive` in favor of [Action Mailbox ](https://github.com/rails/rails/tree/6-1-stable/actionmailbox ).
2020-05-04 23:57:39 -04:00
### Deprecations
### Notable changes
Active Record
-------------
Please refer to the [Changelog][active-record] for detailed changes.
### Removals
2020-05-07 15:21:23 -04:00
2020-05-07 15:51:03 -04:00
* Remove deprecated methods from `ActiveRecord::ConnectionAdapters::DatabaseLimits` .
`column_name_length`
`table_name_length`
`columns_per_table`
`indexes_per_table`
`columns_per_multicolumn_index`
`sql_query_length`
`joins_per_query`
2020-05-07 15:36:59 -04:00
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?` .
2020-05-07 15:21:23 -04:00
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?` .
2020-05-04 23:57:39 -04:00
2020-05-07 15:16:15 -04:00
* Remove deprecated `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?` .
2020-05-07 14:36:23 -04:00
* Remove deprecated `ActiveRecord::Base#update_attributes` and `ActiveRecord::Base#update_attributes!` .
2020-05-07 12:32:44 -04:00
* Remove deprecated `migrations_path` argument in
`ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version` .
2020-05-07 12:10:22 -04:00
* Remove deprecated `config.active_record.sqlite3.represent_boolean_as_integer` .
2020-05-07 00:23:18 -04:00
* Remove deprecated methods from `ActiveRecord::DatabaseConfigurations` .
`fetch`
`each`
`first`
`values`
`[]=`
2020-05-06 23:03:58 -04:00
* Remove deprecated `ActiveRecord::Result#to_hash` method.
2020-05-06 22:55:55 -04:00
* Remove deprecated support for using unsafe raw SQL in `ActiveRecord::Relation` methods.
2020-05-04 23:57:39 -04:00
### Deprecations
2020-05-06 22:55:55 -04:00
* Deprecate `ActiveRecord::Base.allow_unsafe_raw_sql` .
2020-12-17 14:41:00 -05:00
* Deprecate `database` kwarg on `connected_to` .
* Deprecate `connection_handlers` when `legacy_connection_handling` is set to false.
2020-05-04 23:57:39 -04:00
### Notable changes
2020-10-29 21:36:25 -04:00
* MySQL: Uniqueness validator now respects default database collation,
2021-05-31 06:11:28 -04:00
no longer enforce case-sensitive comparison by default.
2020-10-29 21:36:25 -04:00
2021-05-31 06:11:28 -04:00
* `relation.create` does no longer leak scope to class-level querying methods
2020-05-07 05:30:33 -04:00
in initialization block and callbacks.
Before:
2020-12-25 10:59:57 -05:00
```ruby
User.where(name: "John").create do |john|
User.find_by(name: "David") # => nil
end
```
2020-05-07 05:30:33 -04:00
After:
2020-12-25 10:59:57 -05:00
```ruby
User.where(name: "John").create do |john|
User.find_by(name: "David") # => #< User name: " David " , . . . >
end
```
2020-05-07 05:30:33 -04:00
2021-05-31 06:11:28 -04:00
* Named scope chain does no longer leak scope to class-level querying methods.
2020-05-07 05:30:33 -04:00
2020-12-25 10:59:57 -05:00
```ruby
class User < ActiveRecord::Base
scope :david, -> { User.where(name: "David") }
end
```
2020-05-07 05:30:33 -04:00
Before:
2020-12-25 10:59:57 -05:00
```ruby
User.where(name: "John").david
# SELECT * FROM users WHERE name = 'John' AND name = 'David'
```
2020-05-07 05:30:33 -04:00
After:
2020-12-25 10:59:57 -05:00
```ruby
User.where(name: "John").david
# SELECT * FROM users WHERE name = 'David'
```
2020-05-07 05:30:33 -04:00
2020-05-07 00:00:27 -04:00
* `where.not` now generates NAND predicates instead of NOR.
2020-12-23 16:14:18 -05:00
Before:
2020-05-07 00:00:27 -04:00
2020-12-25 10:59:57 -05:00
```ruby
User.where.not(name: "Jon", role: "admin")
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
```
2020-05-07 00:00:27 -04:00
2020-12-23 16:14:18 -05:00
After:
2020-05-07 00:00:27 -04:00
2020-12-25 10:59:57 -05:00
```ruby
User.where.not(name: "Jon", role: "admin")
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
```
2020-05-07 00:00:27 -04:00
2020-12-23 16:14:18 -05:00
* To use the new per-database connection handling applications must change
`legacy_connection_handling` to false and remove deprecated accessors on
`connection_handlers` . Public methods for `connects_to` and `connected_to`
require no changes.
2020-12-17 14:41:00 -05:00
2020-05-04 23:57:39 -04:00
Active Storage
--------------
Please refer to the [Changelog][active-storage] for detailed changes.
### Removals
2020-05-11 13:58:19 -04:00
* Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing` .
2020-05-11 13:31:37 -04:00
* Remove deprecated `ActiveStorage::Transformers::MiniMagickTransformer` .
2020-05-07 16:25:22 -04:00
* Remove deprecated `config.active_storage.queue` .
2020-05-07 16:13:56 -04:00
* Remove deprecated `ActiveStorage::Downloading` .
2020-05-04 23:57:39 -04:00
### Deprecations
2020-05-11 13:43:33 -04:00
* Deprecate `Blob.create_after_upload` in favor of `Blob.create_and_upload` .
([Pull Request](https://github.com/rails/rails/pull/34827))
2020-05-04 23:57:39 -04:00
### Notable changes
2020-05-11 13:43:33 -04:00
* Add `Blob.create_and_upload` to create a new blob and upload the given `io`
to the service.
([Pull Request](https://github.com/rails/rails/pull/34827))
2020-12-16 23:03:48 -05:00
* `ActiveStorage::Blob#service_name` column was added. It is required that a migration is run after the upgrade. Run `bin/rails app:update` to generate that migration.
2020-05-11 13:43:33 -04:00
2020-05-04 23:57:39 -04:00
Active Model
------------
Please refer to the [Changelog][active-model] for detailed changes.
### Removals
### Deprecations
### Notable changes
2020-10-29 21:25:03 -04:00
* Active Model's errors are now objects with an interface that allows your application to more
easily handle and interact with errors thrown by models.
[The feature ](https://github.com/rails/rails/pull/32313 ) includes a query interface, enables
more precise testing, and access to error details.
2020-05-04 23:57:39 -04:00
Active Support
--------------
Please refer to the [Changelog][active-support] for detailed changes.
### Removals
2021-03-22 17:15:17 -04:00
* Remove deprecated fallback to `I18n.default_locale` when `config.i18n.fallbacks` is empty.
2020-10-28 17:05:48 -04:00
2020-10-28 17:10:24 -04:00
* Remove deprecated `LoggerSilence` constant.
2020-10-28 17:41:16 -04:00
* Remove deprecated `ActiveSupport::LoggerThreadSafeLevel#after_initialize` .
2020-10-28 17:44:11 -04:00
* Remove deprecated `Module#parent_name` , `Module#parent` and `Module#parents` .
2020-10-28 17:47:56 -04:00
* Remove deprecated file `active_support/core_ext/module/reachable` .
2020-10-28 17:51:17 -04:00
* Remove deprecated file `active_support/core_ext/numeric/inquiry` .
2020-10-28 17:53:08 -04:00
* Remove deprecated file `active_support/core_ext/array/prepend_and_append` .
2020-10-28 17:56:03 -04:00
* Remove deprecated file `active_support/core_ext/hash/compact` .
2020-10-28 18:02:52 -04:00
* Remove deprecated file `active_support/core_ext/hash/transform_values` .
2020-10-28 18:12:00 -04:00
* Remove deprecated file `active_support/core_ext/range/include_range` .
2020-10-28 18:25:13 -04:00
* Remove deprecated `ActiveSupport::Multibyte::Chars#consumes?` and `ActiveSupport::Multibyte::Chars#normalize` .
2020-10-29 11:43:33 -04:00
* Remove deprecated `ActiveSupport::Multibyte::Unicode.pack_graphemes` ,
`ActiveSupport::Multibyte::Unicode.unpack_graphemes` ,
`ActiveSupport::Multibyte::Unicode.normalize` ,
`ActiveSupport::Multibyte::Unicode.downcase` ,
`ActiveSupport::Multibyte::Unicode.upcase` and `ActiveSupport::Multibyte::Unicode.swapcase` .
2020-10-29 12:33:37 -04:00
* Remove deprecated `ActiveSupport::Notifications::Instrumenter#end=` .
2020-05-04 23:57:39 -04:00
### Deprecations
2020-10-29 12:07:24 -04:00
* Deprecate `ActiveSupport::Multibyte::Unicode.default_normalization_form` .
2020-05-04 23:57:39 -04:00
### Notable changes
Active Job
----------
Please refer to the [Changelog][active-job] for detailed changes.
### Removals
### Deprecations
2020-05-06 20:44:44 -04:00
* Deprecate `config.active_job.return_false_on_aborted_enqueue` .
2020-05-04 23:57:39 -04:00
### Notable changes
2020-05-06 20:44:44 -04:00
* Return `false` when enqueuing a job is aborted.
2020-05-11 13:43:33 -04:00
Action Text
----------
Please refer to the [Changelog][action-text] for detailed changes.
### Removals
### Deprecations
### Notable changes
* Add method to confirm rich text content existence by adding `?` after
name of the rich text attribute.
([Pull Request](https://github.com/rails/rails/pull/37951))
* Add `fill_in_rich_text_area` system test case helper to find a trix
editor and fill it with given HTML content.
([Pull Request](https://github.com/rails/rails/pull/35885))
2020-10-30 15:53:35 -04:00
* Add `ActionText::FixtureSet.attachment` to generate
`<action-text-attachment>` elements in database fixtures.
([Pull Request](https://github.com/rails/rails/pull/40289))
2020-05-11 13:43:33 -04:00
Action Mailbox
----------
Please refer to the [Changelog][action-mailbox] for detailed changes.
### Removals
### Deprecations
### Notable changes
2020-05-04 23:57:39 -04:00
Ruby on Rails Guides
--------------------
Please refer to the [Changelog][guides] for detailed changes.
### Notable changes
Credits
-------
See the
[full list of contributors to Rails ](https://contributors.rubyonrails.org/ )
for the many people who spent many hours making Rails, the stable and robust
framework it is. Kudos to all of them.
2021-01-19 15:43:24 -05:00
[railties]: https://github.com/rails/rails/blob/6-1-stable/railties/CHANGELOG.md
[action-pack]: https://github.com/rails/rails/blob/6-1-stable/actionpack/CHANGELOG.md
[action-view]: https://github.com/rails/rails/blob/6-1-stable/actionview/CHANGELOG.md
[action-mailer]: https://github.com/rails/rails/blob/6-1-stable/actionmailer/CHANGELOG.md
[action-cable]: https://github.com/rails/rails/blob/6-1-stable/actioncable/CHANGELOG.md
[active-record]: https://github.com/rails/rails/blob/6-1-stable/activerecord/CHANGELOG.md
[active-storage]: https://github.com/rails/rails/blob/6-1-stable/activestorage/CHANGELOG.md
[active-model]: https://github.com/rails/rails/blob/6-1-stable/activemodel/CHANGELOG.md
[active-support]: https://github.com/rails/rails/blob/6-1-stable/activesupport/CHANGELOG.md
[active-job]: https://github.com/rails/rails/blob/6-1-stable/activejob/CHANGELOG.md
[action-text]: https://github.com/rails/rails/blob/6-1-stable/actiontext/CHANGELOG.md
[action-mailbox]: https://github.com/rails/rails/blob/6-1-stable/actionmailbox/CHANGELOG.md
[guides]: https://github.com/rails/rails/blob/6-1-stable/guides/CHANGELOG.md