Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
More atrubyonrails.org:

Ruby on Rails 6.1 Release Notes

Highlights in Rails 6.1:

  • Per-database Connection Switching
  • Horizontal Sharding
  • Strict Loading Associations
  • Delegated Types
  • Destroy Associations Async

These release notes cover only the major changes. To learn about various bugfixes and changes, please refer to the changelogs or check out thelist ofcommits in the main Railsrepository on GitHub.

1. Upgrading to Rails 6.1

If you're upgrading an existing application, it's a great idea to have good testcoverage before going in. You should also first upgrade to Rails 6.0 in case youhaven't and make sure your application still runs as expected before attemptingan update to Rails 6.1. A list of things to watch out for when upgrading isavailable in theUpgrading Ruby on Railsguide.

2. Major Features

2.1. Per-database Connection Switching

Rails 6.1 provides you with the ability toswitch connections per-database. In 6.0 if you switched to thereading role then all database connections also switched to the reading role. Now in 6.1 if you setlegacy_connection_handling tofalse in your configuration, Rails will allow you to switch connections for a single database by callingconnected_to on the corresponding abstract class.

2.2. Horizontal Sharding

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 andhorizontal sharding with Rails is available.

2.3. Strict Loading Associations

Strict loading associations allows you to ensure that allyour associations are loaded eagerly and stop N+1's before they happen.

2.4. Delegated Types

Delegated Types 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.

2.5. Destroy Associations Async

Destroy associations async adds the ability for applications todestroy associations in a background job. This can help you avoid timeouts and other performance issues in your application when destroying data.

3. Railties

Please refer to theChangelog for detailed changes.

3.1. Removals

  • Remove deprecatedrake notes tasks.

  • Remove deprecatedconnection option in therails dbconsole command.

  • Remove deprecatedSOURCE_ANNOTATION_DIRECTORIES environment variable support fromrails notes.

  • Remove deprecatedserver argument from the rails server command.

  • Remove deprecated support for using theHOST environment variable to specify the server IP.

  • Remove deprecatedrake dev:cache tasks.

  • Remove deprecatedrake routes tasks.

  • Remove deprecatedrake initializers tasks.

3.2. Deprecations

3.3. Notable changes

4. Action Cable

Please refer to theChangelog for detailed changes.

4.1. Removals

4.2. Deprecations

4.3. Notable changes

5. Action Pack

Please refer to theChangelog for detailed changes.

5.1. Removals

  • Remove deprecatedActionDispatch::Http::ParameterFilter.

  • Remove deprecatedforce_ssl at the controller level.

5.2. Deprecations

  • Deprecateconfig.action_dispatch.return_only_media_type_on_content_type.

5.3. Notable changes

  • ChangeActionDispatch::Response#content_type to return the full Content-Type header.

6. Action View

Please refer to theChangelog for detailed changes.

6.1. Removals

  • Remove deprecatedescape_whitelist fromActionView::Template::Handlers::ERB.

  • Remove deprecatedfind_all_anywhere fromActionView::Resolver.

  • Remove deprecatedformats fromActionView::Template::HTML.

  • Remove deprecatedformats fromActionView::Template::RawFile.

  • Remove deprecatedformats fromActionView::Template::Text.

  • Remove deprecatedfind_file fromActionView::PathSet.

  • Remove deprecatedrendered_format fromActionView::LookupContext.

  • Remove deprecatedfind_file fromActionView::ViewPaths.

  • Remove deprecated support to pass an object that is not aActionView::LookupContext as the first argumentinActionView::Base#initialize.

  • Remove deprecatedformat argumentActionView::Base#initialize.

  • Remove deprecatedActionView::Template#refresh.

  • Remove deprecatedActionView::Template#original_encoding.

  • Remove deprecatedActionView::Template#variants.

  • Remove deprecatedActionView::Template#formats.

  • Remove deprecatedActionView::Template#virtual_path=.

  • Remove deprecatedActionView::Template#updated_at.

  • Remove deprecatedupdated_at argument required onActionView::Template#initialize.

  • Remove deprecatedActionView::Template.finalize_compiled_template_methods.

  • Remove deprecatedconfig.action_view.finalize_compiled_template_methods

  • Remove deprecated support to callingActionView::ViewPaths#with_fallback with a block.

  • Remove deprecated support to passing absolute paths torender template:.

  • Remove deprecated support to passing relative paths torender file:.

  • Remove support to template handlers that don't accept two arguments.

  • Remove deprecated pattern argument inActionView::Template::PathResolver.

  • Remove deprecated support to call private methods from object in some view helpers.

6.2. Deprecations

6.3. Notable changes

  • Require thatActionView::Base subclasses implement#compiled_method_container.

  • Makelocals argument required onActionView::Template#initialize.

  • Thejavascript_include_tag andstylesheet_link_tag asset helpers generate alink header that gives hints to modern browsers about preloading assets. This can be disabled by settingconfig.action_view.preload_links_header tofalse.

7. Action Mailer

Please refer to theChangelog for detailed changes.

7.1. Removals

  • Remove deprecatedActionMailer::Base.receive in favor ofAction Mailbox.

7.2. Deprecations

7.3. Notable changes

8. Active Record

Please refer to theChangelog for detailed changes.

8.1. Removals

  • Remove deprecated methods fromActiveRecord::ConnectionAdapters::DatabaseLimits.

    column_name_lengthtable_name_lengthcolumns_per_tableindexes_per_tablecolumns_per_multicolumn_indexsql_query_lengthjoins_per_query

  • Remove deprecatedActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?.

  • Remove deprecatedActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?.

  • Remove deprecatedActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?.

  • Remove deprecatedActiveRecord::Base#update_attributes andActiveRecord::Base#update_attributes!.

  • Remove deprecatedmigrations_path argument inActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version.

  • Remove deprecatedconfig.active_record.sqlite3.represent_boolean_as_integer.

  • Remove deprecated methods fromActiveRecord::DatabaseConfigurations.

    fetcheachfirstvalues[]=

  • Remove deprecatedActiveRecord::Result#to_hash method.

  • Remove deprecated support for using unsafe raw SQL inActiveRecord::Relation methods.

8.2. Deprecations

  • DeprecateActiveRecord::Base.allow_unsafe_raw_sql.

  • Deprecatedatabase kwarg onconnected_to.

  • Deprecateconnection_handlers whenlegacy_connection_handling is set to false.

8.3. Notable changes

  • MySQL: Uniqueness validator now respects default database collation,no longer enforce case-sensitive comparison by default.

  • relation.create does no longer leak scope to class-level querying methodsin initialization block and callbacks.

    Before:

    User.where(name:"John").createdo|john|User.find_by(name:"David")# => nilend

    After:

    User.where(name:"John").createdo|john|User.find_by(name:"David")# => #<User name: "David", ...>end
  • Named scope chain does no longer leak scope to class-level querying methods.

    classUser<ActiveRecord::Basescope:david,->{User.where(name:"David")}end

    Before:

    User.where(name:"John").david# SELECT * FROM users WHERE name = 'John' AND name = 'David'

    After:

    User.where(name:"John").david# SELECT * FROM users WHERE name = 'David'
  • where.not now generates NAND predicates instead of NOR.

    Before:

    User.where.not(name:"Jon",role:"admin")# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'

    After:

    User.where.not(name:"Jon",role:"admin")# SELECT * FROM users WHERE NOT (name = 'Jon' AND role = 'admin')
  • To use the new per-database connection handling applications must changelegacy_connection_handling to false and remove deprecated accessors onconnection_handlers. Public methods forconnects_to andconnected_torequire no changes.

9. Active Storage

Please refer to theChangelog for detailed changes.

9.1. Removals

  • Remove deprecated support to pass:combine_options operations toActiveStorage::Transformers::ImageProcessing.

  • Remove deprecatedActiveStorage::Transformers::MiniMagickTransformer.

  • Remove deprecatedconfig.active_storage.queue.

  • Remove deprecatedActiveStorage::Downloading.

9.2. Deprecations

  • DeprecateBlob.create_after_upload in favor ofBlob.create_and_upload.(Pull Request)

9.3. Notable changes

  • AddBlob.create_and_upload to create a new blob and upload the givenioto the service.(Pull Request)
  • ActiveStorage::Blob#service_name column was added. It is required that a migration is run after the upgrade. Runbin/rails app:update to generate that migration.

10. Active Model

Please refer to theChangelog for detailed changes.

10.1. Removals

10.2. Deprecations

10.3. Notable changes

  • Active Model's errors are now objects with an interface that allows your application to moreeasily handle and interact with errors thrown by models.The feature includes a query interface, enablesmore precise testing, and access to error details.

11. Active Support

Please refer to theChangelog for detailed changes.

11.1. Removals

  • Remove deprecated fallback toI18n.default_locale whenconfig.i18n.fallbacks is empty.

  • Remove deprecatedLoggerSilence constant.

  • Remove deprecatedActiveSupport::LoggerThreadSafeLevel#after_initialize.

  • Remove deprecatedModule#parent_name,Module#parent andModule#parents.

  • Remove deprecated fileactive_support/core_ext/module/reachable.

  • Remove deprecated fileactive_support/core_ext/numeric/inquiry.

  • Remove deprecated fileactive_support/core_ext/array/prepend_and_append.

  • Remove deprecated fileactive_support/core_ext/hash/compact.

  • Remove deprecated fileactive_support/core_ext/hash/transform_values.

  • Remove deprecated fileactive_support/core_ext/range/include_range.

  • Remove deprecatedActiveSupport::Multibyte::Chars#consumes? andActiveSupport::Multibyte::Chars#normalize.

  • Remove deprecatedActiveSupport::Multibyte::Unicode.pack_graphemes,ActiveSupport::Multibyte::Unicode.unpack_graphemes,ActiveSupport::Multibyte::Unicode.normalize,ActiveSupport::Multibyte::Unicode.downcase,ActiveSupport::Multibyte::Unicode.upcase andActiveSupport::Multibyte::Unicode.swapcase.

  • Remove deprecatedActiveSupport::Notifications::Instrumenter#end=.

11.2. Deprecations

  • DeprecateActiveSupport::Multibyte::Unicode.default_normalization_form.

11.3. Notable changes

12. Active Job

Please refer to theChangelog for detailed changes.

12.1. Removals

12.2. Deprecations

  • Deprecateconfig.active_job.return_false_on_aborted_enqueue.

12.3. Notable changes

  • Returnfalse when enqueuing a job is aborted.

13. Action Text

Please refer to theChangelog for detailed changes.

13.1. Removals

13.2. Deprecations

13.3. Notable changes

  • Add method to confirm rich text content existence by adding? aftername of the rich text attribute.(Pull Request)

  • Addfill_in_rich_text_area system test case helper to find a trixeditor and fill it with given HTML content.(Pull Request)

  • AddActionText::FixtureSet.attachment to generate<action-text-attachment> elements in database fixtures.(Pull Request)

14. Action Mailbox

Please refer to theChangelog for detailed changes.

14.1. Removals

14.2. Deprecations

  • DeprecateRails.application.credentials.action_mailbox.api_key andMAILGUN_INGRESS_API_KEY in favor ofRails.application.credentials.action_mailbox.signing_key andMAILGUN_INGRESS_SIGNING_KEY.

14.3. Notable changes

15. Ruby on Rails Guides

Please refer to theChangelog for detailed changes.

15.1. Notable changes

16. Credits

See thefull list of contributors to Railsfor the many people who spent many hours making Rails, the stable and robustframework it is. Kudos to all of them.



Back to top
[8]ページ先頭

©2009-2025 Movatter.jp