22 KiB
DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON https://guides.rubyonrails.org.
Ruby on Rails 6.0 Release Notes
Highlights in Rails 6.0:
- Action Mailbox
- Action Text
- Parallel Testing
- Action Cable Testing
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 in the main Rails repository on GitHub.
Upgrading to Rails 6.0
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 5.2 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 6.0. A list of things to watch out for when upgrading is available in the Upgrading Ruby on Rails guide.
Major Features
Action Mailbox
Action Mailbox allows you to route incoming emails to controller-like mailboxes. You can read more about Action Mailbox in the Action Mailbox Basics guide.
Action Text
Action Text brings rich text content and editing to Rails. It includes the Trix editor that handles everything from formatting to links to quotes to lists to embedded images and galleries. The rich text content generated by the Trix editor is saved in its own RichText model that's associated with any existing Active Record model in the application. Any embedded images (or other attachments) are automatically stored using Active Storage and associated with the included RichText model.
You can read more about Action Text in the Action Text Overview guide.
Parallel Testing
Parallel Testing allows you to parallelize your test suite. While forking processes is the default method, threading is supported as well. Running tests in parallel reduces the time it takes your entire test suite to run.
Action Cable Testing
Action Cable testing tools allow you to test your Action Cable functionality at any level: connections, channels, broadcasts.
Railties
Please refer to the Changelog for detailed changes.
Removals
-
Remove deprecated
after_bundle
helper inside plugins templates. (Commit) -
Remove deprecated support to
config.ru
that uses the application class as argument ofrun
. (Commit) -
Remove deprecated
environment
argument from the rails commands. (Commit) -
Remove deprecated
capify!
method in generators and templates. (Commit) -
Remove deprecated
config.secret_token
. (Commit)
Deprecations
-
Deprecate passing Rack server name as a regular argument to
rails server
. (Pull Request) -
Deprecate support for using
HOST
environment to specify server IP. (Pull Request) -
Deprecate accessing hashes returned by
config_for
by non-symbol keys. (Pull Request)
Notable changes
-
Add an explicit option
--using
or-u
for specifying the server for therails server
command. (Pull Request) -
Add ability to see the output of
rails routes
in expanded format. (Pull Request) -
Run the seed database task using inline Active Job adapter. (Pull Request)
-
Add a command
rails db:system:change
to change the database of the application. (Pull Request) -
Add
rails test:channels
command to test only Action Cable channels. (Pull Request) -
Introduce guard against DNS rebinding attacks. (Pull Request)
-
Add ability to abort on failure while running generator commands. (Pull Request)
-
Make Webpacker the default JavaScript compiler for Rails 6. (Pull Request)
-
Add multiple database support for
rails db:migrate:status
command. (Pull Request) -
Add ability to use different migration paths from multiple databases in the generators. (Pull Request)
-
Add support for multi environment credentials. (Pull Request)
-
Make
null_store
as default cache store in test environment. (Pull Request)
Action Cable
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
-
The ActionCable javascript package has been converted from CoffeeScript to ES2015, and we now publish the source code in the npm distribution.
This allows ActionCable users to depend on the javascript source code rather than the compiled code, which can produce smaller javascript bundles.
This change includes some breaking changes to optional parts of the ActionCable javascript API:
-
Configuration of the WebSocket adapter and logger adapter have been moved from properties of
ActionCable
to properties ofActionCable.adapters
. -
The
ActionCable.startDebugging()
andActionCable.stopDebugging()
methods have been removed and replaced with the propertyActionCable.logger.enabled
.
-
Action Pack
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
Action View
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
Action Mailer
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
Active Record
Please refer to the Changelog for detailed changes.
Removals
-
Remove deprecated
#set_state
from the transaction object. (Commit) -
Remove deprecated
#supports_statement_cache?
from the database adapters. (Commit) -
Remove deprecated
#insert_fixtures
from the database adapters. (Commit) -
Remove deprecated
ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?
. (Commit) -
Remove support for passing the column name to
sum
when a block is passed. (Commit) -
Remove support for passing the column name to
count
when a block is passed. (Commit) -
Remove support for delegation of missing methods in a relation to arel. (Commit)
-
Remove support for delegating missing methods in a relation to private methods of the class. (Commit)
-
Remove support for specifying a timestamp name for
#cache_key
. (Commit) -
Remove deprecated
ActiveRecord::Migrator.migrations_path=
. (Commit) -
Remove deprecated
expand_hash_conditions_for_aggregates
. (Commit)
Deprecations
-
Deprecate mismatched case-sensitivity collation comparisons for uniqueness validator. (Commit)
-
Deprecate using class level querying methods if the receiver scope has leaked. (Pull Request)
-
Deprecate
config.activerecord.sqlite3.represent_boolean_as_integer
. (Commit) -
Deprecate passing
migrations_paths
toconnection.assume_migrated_upto_version
. (Commit) -
Deprecate
ActiveRecord::Result#to_hash
in favor ofActiveRecord::Result#to_a
. (Commit) -
Deprecate methods in
DatabaseLimits
:column_name_length
,table_name_length
,columns_per_table
,indexes_per_table
,columns_per_multicolumn_index
,sql_query_length
, andjoins_per_query
. (Commit) -
Deprecate
update_attributes
/!
in favor ofupdate
/!
. (Commit)
Notable changes
-
Bump the minimum sqlite3 version to 1.4. (Pull Request)
-
Add
rails db:prepare
to create a database if it doesn't exist, and run its migrations. (Pull Request) -
Add
after_save_commit
callback as shortcut forafter_commit :hook, on: [ :create, :update ]
. (Pull Request) -
Add
ActiveRecord::Relation#extract_associated
for extracting associated records from a relation. (Pull Request) -
Add
ActiveRecord::Relation#annotate
for adding SQL comments to ActiveRecord::Relation queries. (Pull Request) -
Add support for setting Optimizer Hints on databases. (Pull Request)
-
Add
insert_all
/insert_all!
/upsert_all
methods for doing bulk inserts. (Pull Request) -
Add
rails db:seed:replant
that truncates tables of each database for ther current environment and loads the seeds. (Pull Request) -
Add
reselect
method, which is a short-hand forunscope(:select).select(fields)
. (Pull Request) -
Add negative scopes for all enum values. (Pull Request)
-
Add
#destroy_by
and#delete_by
for conditional removals. (Pull Request) -
Add the ability to automatically switch database connections. (Pull Request)
-
Add the ability to prevent writes to a database for the duration of a block. (Pull Request)
-
Add an API for switching connections to support multiple databases. (Pull Request)
-
Make timestamps with precision the default for migrations. (Pull Request)
-
Support
:size
option to change text and blob size in MySQL. (Pull Request) -
Set both the foreign key and the foreign type columns to NULL for polymorphic associations on
dependent: :nullify
strategy. (Pull Request) -
Allow a permitted instance of
ActionController::Parameters
to be passed as an argument toActiveRecord::Relation#exists?
. (Pull Request) -
Add support in
#where
for endless ranges introduced in Ruby 2.6. (Pull Request) -
Make
ROW_FORMAT=DYNAMIC
a default create table option for MySQL. (Pull Request) -
Add the ability to disable scopes generated by
ActiveRecord.enum
. (Pull Request) -
Make implicit ordering configurable for a column. (Pull Request)
-
Bump the minimum PostgreSQL version to 9.3, dropping support for 9.1 and 9.2. (Pull Request)
-
Make the values of an enum frozen, raising an error when attempting to modify them. (Pull Request)
-
Make the SQL of
ActiveRecord::StatementInvalid
errors its own error property and include SQL binds as a separate error property. (Pull Request) -
Add an
:if_not_exists
option tocreate_table
. (Pull Request) -
Add support for multiple databases to
rails db:schema:cache:dump
andrails db:schema:cache:clear
. (Pull Request) -
Add support for hash and url configs in database hash of
ActiveRecord::Base.connected_to
. (Pull Request) -
Add support for default expressions and expression indexes for MySQL. (Pull Request)
-
Add an
index
option forchange_table
migration helpers. (Pull Request) -
Fix
transaction
reverting for migrations. Previously, commands inside of atransaction
in a reverted migration ran uninverted. This change fixes that. (Pull Request) -
Allow
ActiveRecord::Base.configurations=
to be set with a symbolized hash. (Pull Request) -
Fix the counter cache to only update if the record is actually saved. (Pull Request)
-
Add expression indexes support for the SQLite adapter. (Pull Request)
-
Allow subclasses to redefine autosave callbacks for associated records. (Pull Request)
-
Bump the minimum MySQL version to 5.5.8. (Pull Request)
-
Use the utf8mb4 character set by default in MySQL. (Pull Request)
-
Add the ability to filter out sensitive data in
#inspect
(Pull Request, Pull Request) -
Change
ActiveRecord::Base.configurations
to return an object instead of a hash. (Pull Request) -
Add database configuration to disable advisory locks. (Pull Request)
-
Update SQLite3 adapter
alter_table
method to restore foreign keys. (Pull Request) -
Allow the
:to_table
option ofremove_foreign_key
to be invertible. (Pull Request) -
Fix default value for mysql time types with specified precision. (Pull Request)
-
Fix the
touch
option to behave consistently withPersistence#touch
method. (Pull Request) -
Raise an exception for duplicate column definitions in Migrations. (Pull Request)
-
Bump the minimum SQLite version to 3.8. (Pull Request)
-
Fix parent records to not get saved with duplicate children records. (Pull Request)
-
Ensure
Associations::CollectionAssociation#size
andAssociations::CollectionAssociation#empty?
use loaded association ids if present. (Pull Request) -
Add support to preload associations of polymorphic associations when not all the records have the requested associations. (Commit)
-
Add
touch_all
method toActiveRecord::Relation
. (Pull Request) -
Add
ActiveRecord::Base.base_class?
predicate. (Pull Request) -
Add custom prefix/suffix options to
ActiveRecord::Store.store_accessor
. (Pull Request) -
Add
ActiveRecord::Base.create_or_find_by
/!
to deal with the SELECT/INSERT race condition inActiveRecord::Base.find_or_create_by
/!
by leaning on unique constraints in the database. (Pull Request) -
Add
Relation#pick
as short-hand for single-value plucks. (Pull Request)
Active Storage
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
Active Model
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
-
Add a configuration option to customize format of the
ActiveModel::Errors#full_message
. (Pull Request) -
Add support for configuring attribute name for
has_secure_password
. (Pull Request) -
Add
#slice!
method toActiveModel::Errors
. (Pull Request) -
Add
ActiveModel::Errors#of_kind?
to check presence of a specific error. (Pull Request)
Active Support
Please refer to the Changelog for detailed changes.
Removals
Deprecations
Notable changes
Active Job
Please refer to the Changelog for detailed changes.
Removals
- Remove support for Qu gem. (Pull Request)
Deprecations
Notable changes
-
Add support for custom serializers for Active Job arguments. (Pull Request)
-
Add support for executing Active Jobs in the timezone in which they were enqueued. (Pull Request)
-
Allow passing multiple exceptions to
retry_on
/discard_on
. (Commit) -
Allow calling
assert_enqueued_with
andassert_enqueued_email_with
without a block. (Pull Request) -
Wrap the notifications for
enqueue
andenqueue_at
in thearound_enqueue
callback instead ofafter_enqueue
callback. (Pull Request) -
Allow calling
perform_enqueued_jobs
without a block. (Pull Request) -
Allow calling
assert_performed_with
without a block. (Pull Request) -
Add
:queue
option to job assertions and helpers. (Pull Request) -
Add hooks to Active Job around retries and discards. (Pull Request)
-
Add a way to test for subset of arguments when performing jobs. (Pull Request)
-
Include deserialized arguments in jobs returned by Active Job test helpers. (Pull Request)
-
Allow Active Job assertion helpers to accept Proc for
only
keyword. (Pull Request) -
Drop microseconds and nanoseconds from the job arguments in assertion helpers. (Pull Request)
Ruby on Rails Guides
Please refer to the Changelog for detailed changes.
Notable changes
Credits
See the full list of contributors to Rails for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.