1. Upgrading to Rails 8.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 8.1 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 8.1. A list of things to watch out for when upgrading is available in the Upgrading Ruby on Rails guide.
2. Major Features
3. Railties
Please refer to the Changelog for detailed changes.
3.1. Removals
3.2. Deprecations
3.3. Notable changes
Add
Rails.appas an alias forRails.application.Add
Rails.app.revisionto provide a version identifier for error reporting, monitoring, and cache keys. By default it reads from aREVISIONfile or the local git SHA.Add
Rails.app.credsfor combined access to credentials stored in either ENV or the encrypted credentials file, withrequireandoptionmethods.
4. Action Cable
Please refer to the Changelog for detailed changes.
4.1. Removals
4.2. Deprecations
4.3. Notable changes
5. Action Pack
Please refer to the Changelog for detailed changes.
5.1. Removals
5.2. Deprecations
Deprecate calling
protect_from_forgerywithout specifying a strategy.The current default of
:null_sessionis inconsistent withconfig.action_controller.default_protect_from_forgery, which uses:exception. Explicitly passwith: :null_sessionto silence the warning, or setconfig.action_controller.default_protect_from_forgery_with = :exceptionto opt into the new behavior.Deprecate
InvalidAuthenticityTokenin favor ofInvalidCrossOriginRequest, as part of the new header-based CSRF protection.
5.3. Notable changes
- Add modern header-based CSRF protection using the
Sec-Fetch-Siteheader to verify same-origin requests without requiring authenticity tokens. Two strategies are available viaprotect_from_forgery using:::header_only(default for new 8.2 apps) and:header_or_legacy_token(falls back to token verification for older browsers).
6. Action View
Please refer to the Changelog for detailed changes.
6.1. Removals
6.2. Deprecations
6.3. Notable changes
- Add ability to pass a block when rendering a collection. The block is executed for each rendered element in the collection.
7. Action Mailer
Please refer to the Changelog for detailed changes.
7.1. Removals
7.2. Deprecations
7.3. Notable changes
8. Active Record
Please refer to the Changelog for detailed changes.
8.1. Removals
8.2. Deprecations
8.3. Notable changes
PostgreSQL
DROP DATABASEnow automatically uses theFORCEoption on supported versions, disconnecting clients before dropping. This allowsbin/rails db:resetand similar commands to work without first shutting down running app instances or consoles.Fix SQLite3 data loss during table alterations when child tables have
ON DELETE CASCADEforeign keys. Schema changes no longer silently trigger CASCADE deletes on child tables.Add
implicit_persistence_transactionhook for customizing transaction behavior. This protected method wrapssave,destroy, andtouchin a transaction and can be overridden in models to set a specific isolation level or skip transaction creation when one is already open.
9. Active Storage
Please refer to the Changelog for detailed changes.
9.1. Removals
9.2. Deprecations
- Deprecate
preprocessed: truevariant option in favor ofprocess: :later.
9.3. Notable changes
Analyze attachments before validation. Attachment metadata (width, height, duration, etc.) is now available for model validations. Configure timing with
analyze: :immediately(default),:later, or:lazily.Add immediate variant processing via the
process: :immediatelyoption, which generates variants during attachment instead of lazily or in a background job.
10. Active Model
Please refer to the Changelog for detailed changes.
10.1. Removals
10.2. Deprecations
10.3. Notable changes
Add
has_jsonandhas_delegated_jsonto provide schema-enforced access to JSON attributes with type casting and default values.Add built-in Argon2 support for
has_secure_passwordviaalgorithm: :argon2. Argon2 has no password length limit, unlike BCrypt's 72-byte restriction. A newActiveModel::SecurePassword.register_algorithmAPI allows registering custom password hashing algorithms.
11. Active Support
Please refer to the Changelog for detailed changes.
11.1. Removals
11.2. Deprecations
11.3. Notable changes
Add
SecureRandom.base32for generating case-insensitive keys that are unambiguous to humans.Parallel tests are now deterministically assigned to workers in round-robin order, making flaky test failures caused by test interdependence easier to reproduce. Enable
work_stealing: trueto allow idle workers to steal tests from busy workers for faster runtime.
12. Active Job
Please refer to the Changelog for detailed changes.
12.1. Removals
Remove deprecated
sidekiqActive Job adapter.The adapter is available in the
sidekiqgem.
12.2. Deprecations
- Deprecate built-in
queue_classic,resque,delayed_job,backburner, andsneakersActive Job adapters. If usingresque(3.0+) ordelayed_job(4.2.0+), upgrade to use the gem's own adapter.
12.3. Notable changes
- Un-deprecate
config.active_job.enqueue_after_transaction_commitand default it totruefor new applications. This setting was deprecated in 8.0 and non-functional in 8.1; it now works as a boolean config. Jobs are now enqueued after transaction commit by default, fixing jobs that would previously run against uncommitted or rolled-back records.
13. Action Text
Please refer to the Changelog for detailed changes.
13.1. Removals
13.2. Deprecations
- Deprecate Trix-specific classes, modules, and methods:
ActionText::TrixAttachment,ActionText::Attachments::TrixConversion,ActionText::Content#to_trix_html,ActionText::RichText#to_trix_html, andActionText::Attachable#to_trix_content_attachment_partial_path(use#to_editor_content_attachment_partial_pathinstead).
13.3. Notable changes
14. Action Mailbox
Please refer to the Changelog for detailed changes.
14.1. Removals
14.2. Deprecations
14.3. Notable changes
15. Ruby on Rails Guides
Please refer to the Changelog for detailed changes.
15.1. Notable changes
16. 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.