Latest in branch 6.1
6.1.7.10
Released 23 Oct 2024
(1 year ago)
SoftwareRuby on Rails
Version6.1
Status
End of life
Initial release6.1.0
09 Dec 2020
(5 years ago)
Latest release6.1.7.10
23 Oct 2024
(1 year ago)
End of bug fixes15 Dec 2021
(Ended 4 years, 5 months ago)
End of security fixes01 Oct 2024
(Ended 1 year, 7 months ago)
Release noteshttps://github.com/rails/rails/releases/tag/v6.1.7.10
Source codehttps://github.com/rails/rails/tree/v6.1.7.10
Downloadhttps://github.com/rails/rails/releases/tag/v6.1.7.10
Ruby on Rails 6.1 ReleasesView full list

What Is New in Ruby on Rails 6.1

Category Highlights
New Features Per-database connection switching, Horizontal sharding, Strict loading associations, Delegated types, Async destroy of associations
Improvements Where.not now generates NAND predicates, Scope-leakage fixes in create and named scopes, MySQL uniqueness respects collation, ActionView preload_links_header, ActiveModel errors become objects
Breaking Changes Set config.active_record.legacy_connection_handling = false to use new connection handling, Removal of many deprecated rake tasks and ActionCable/ActionPack methods, ActiveStorage requires new Blob.service_name column migration
Deprecations ActiveRecord::Base.update_attributes, config.active_job.return_false_on_aborted_enqueue, ActionView::Template#refresh, ActiveSupport::Multibyte::Unicode.default_normalization_form, and numerous other helpers

How does Rails 6.1 improve database connection handling and sharding?

Rails 6.1 introduces per-database connection switching and native horizontal sharding support.

  • Set config.active_record.legacy_connection_handling = false to enable the new API.
  • Use connected_to on an abstract class to switch only the desired database role.
  • Horizontal sharding is now possible because a model can have separate connections per role.
class ReportingBase < ApplicationRecord
  self.abstract_class = true
  connects_to database: { writing: :primary, reading: :primary_replica }
end

ReportingBase.connected_to(role: :reading) do
  # All queries inside this block use the replica only
end

How can I prevent N+1 queries with the new strict loading feature?

Strict loading forces all associations to be eager-loaded, raising an error if a lazy load occurs.

  • Enable globally with ActiveRecord::Base.strict_loading! or per-model with strict_loading!.
  • When a lazy load is attempted, Rails raises ActiveRecord::StrictLoadingViolationError, letting you catch N+1 problems early.
# Enable strict loading for the whole app
ActiveRecord::Base.strict_loading!

user = User.first          # raises if any association is not preloaded

What options does Rails 6.1 give for model inheritance and background destruction?

Delegated types replace STI for concrete super-classes, and destroy associations can now be queued to a background job.

  • Delegated types let the superclass have its own table while each subclass lives in a separate table.
  • Use dependent: :destroy_async to offload heavy deletions to Active Job.
class Vehicle < ApplicationRecord
  delegated_type :vehicle_type, types: %w[Car Truck], dependent: :destroy
end

class Car < ApplicationRecord; end
class Truck < ApplicationRecord; end

class Post < ApplicationRecord
  has_many :comments, dependent: :destroy_async
end

What query behavior changes should I be aware of in Active Record 6.1?

Where.not now generates NAND predicates, and scope-leakage bugs have been fixed.

  • where.not produces NOT (cond1 AND cond2) instead of separate != clauses.
  • Creating records inside a scoped create block no longer leaks the scope to class-level queries.
  • Named scopes no longer inherit the caller's scope, preventing accidental double-filtering.
User.where.not(name: "Jon", role: "admin")
# => SELECT ... WHERE NOT (name = 'Jon' AND role = 'admin')

What are the notable updates to Action View, Active Storage and Active Model errors?

Action View now requires a compiled method container, preload link headers can be disabled, Active Storage adds a new upload API, and Active Model errors are objects.

  • ActionView subclasses must implement #compiled_method_container.
  • Set config.action_view.preload_links_header = false to stop automatic Link headers.
  • ActiveStorage introduces Blob.create_and_upload and a service_name column (run the migration generated by rails app:update).
  • Model errors are now instances of ActiveModel::Errors with a queryable API.

Frequently Asked Questions

Does upgrading to Rails 6.1 require changes to database configuration?
You must set config.active_record.legacy_connection_handling = false and adjust any custom connected_to calls accordingly.

How do I enable strict loading in an existing Rails app?
Add ActiveRecord::Base.strict_loading! to an initializer or call strict_loading! on individual models.

Can I still use the old connection handling APIs after setting legacy_connection_handling to false?
No, the old connection_handlers accessor is removed when legacy handling is disabled.

What is the recommended way to migrate ActiveStorage after upgrading to 6.1?
Run bin/rails app:update to generate a migration that adds the service_name column to the blobs table.

Are there any performance impacts when using delegated types instead of STI?
Delegated types add a small join to fetch subclass tables but avoid the single-table bloat and can improve query clarity.

How do I silence the new deprecation warnings for removed rake tasks?
Remove the tasks from your Rakefile or replace them with the recommended alternatives; no runtime flag exists.

Releases In Branch 6.1

VersionRelease date
6.1.7.1023 Oct 2024
(1 year ago)
6.1.7.915 Oct 2024
(1 year ago)
6.1.7.804 Jun 2024
(1 year ago)
6.1.7.721 Feb 2024
(2 years ago)
6.1.7.622 Aug 2023
(2 years ago)
6.1.7.522 Aug 2023
(2 years ago)
6.1.7.426 Jun 2023
(2 years ago)
6.1.7.313 Mar 2023
(3 years ago)
6.1.7.224 Jan 2023
(3 years ago)
6.1.7.117 Jan 2023
(3 years ago)
6.1.709 Sep 2022
(3 years ago)
6.1.6.112 Jul 2022
(3 years ago)
6.1.609 May 2022
(4 years ago)
6.1.5.126 Apr 2022
(4 years ago)
6.1.510 Mar 2022
(4 years ago)
6.1.4.708 Mar 2022
(4 years ago)
6.1.4.611 Feb 2022
(4 years ago)
6.1.4.511 Feb 2022
(4 years ago)
6.1.4.415 Dec 2021
(4 years ago)
6.1.4.314 Dec 2021
(4 years ago)
6.1.4.214 Dec 2021
(4 years ago)
6.1.4.119 Aug 2021
(4 years ago)
6.1.424 Jun 2021
(4 years ago)
6.1.3.205 May 2021
(5 years ago)
6.1.3.126 Mar 2021
(5 years ago)
6.1.317 Feb 2021
(5 years ago)
6.1.2.110 Feb 2021
(5 years ago)
6.1.209 Feb 2021
(5 years ago)
6.1.107 Jan 2021
(5 years ago)
6.1.009 Dec 2020
(5 years ago)
6.1.0.rc201 Dec 2020
(5 years ago)
6.1.0.rc102 Nov 2020
(5 years ago)