Ruby on Rails v6.1.0 Release Notes

Release Date: 2020-12-09 // 11 months ago
  • 👍 Active Support

    ⏪ Ensure MemoryStore disables compression by default. Reverts behavior of
    🚅 MemoryStore to its prior rails 5.1 behavior.

    Max Gurewitz

    Calling iso8601 on negative durations retains the negative sign on individual
    digits instead of prepending it.

    This change is required so we can interoperate with PostgreSQL, which prefers
    negative signs for each component.

    📜 Compatibility with other iso8601 parsers which support leading negatives as well
    as negatives per component is still retained.

    Before:

    (-1.year - 1.day).iso8601
    # => "-P1Y1D"
    

    After:

    (-1.year - 1.day).iso8601
    # => "P-1Y-1D"
    

    Vipul A M

    ✂ Remove deprecated ActiveSupport::Notifications::Instrumenter#end=.

    Rafael Mendonça França

    Deprecate ActiveSupport::Multibyte::Unicode.default_normalization_form.

    Rafael Mendonça França

    ✂ 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.

    Rafael Mendonça França

    ✂ Remove deprecated ActiveSupport::Multibyte::Chars#consumes? and ActiveSupport::Multibyte::Chars#normalize.

    Rafael Mendonça França

    👌 Remove deprecated file active_support/core_ext/range/include_range.

    Rafael Mendonça França

    👌 Remove deprecated file active_support/core_ext/hash/transform_values.

    Rafael Mendonça França

    👌 Remove deprecated file active_support/core_ext/hash/compact.

    Rafael Mendonça França

    👌 Remove deprecated file active_support/core_ext/array/prepend_and_append.

    Rafael Mendonça França

    👌 Remove deprecated file active_support/core_ext/numeric/inquiry.

    Rafael Mendonça França

    👌 Remove deprecated file active_support/core_ext/module/reachable.

    Rafael Mendonça França

    ✂ Remove deprecated Module#parent_name, Module#parent and Module#parents.

    Rafael Mendonça França

    ✂ Remove deprecated ActiveSupport::LoggerThreadSafeLevel#after_initialize.

    Rafael Mendonça França

    ✂ Remove deprecated LoggerSilence constant.

    Rafael Mendonça França

    ✂ Remove deprecated fallback to I18n.default_local when config.i18n.fallbacks is empty.

    Rafael Mendonça França

    ✂ Remove entries from local cache on RedisCacheStore#delete_matched

    🛠 Fixes #38627

    ojab

    Speed up ActiveSupport::SecurityUtils.fixed_length_secure_compare by using
    OpenSSL.fixed_length_secure_compare, if available.

    Nate Matykiewicz

    🔧 ActiveSupport::Cache::MemCacheStore now checks ENV["MEMCACHE_SERVERS"] before falling back to "localhost:11211" if configured without any addresses.

    config.cache\_store = :mem\_cache\_store# is now equivalent toconfig.cache\_store = :mem\_cache\_store, ENV["MEMCACHE\_SERVERS"] || "localhost:11211"# instead ofconfig.cache\_store = :mem\_cache\_store, "localhost:11211" # ignores ENV["MEMCACHE\_SERVERS"]
    

    Sam Bostock

    ActiveSupport::Subscriber#attach_to now accepts an inherit_all: argument. When set to true,
    it allows a subscriber to receive events for methods defined in the subscriber's ancestor class(es).

    class ActionControllerSubscriber \< ActiveSupport::Subscriberattach\_to :action\_controllerdef start\_processing(event)info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}"enddef redirect\_to(event)info { "Redirected to #{event.payload[:location]}" }endend# We detach ActionControllerSubscriber from the :action\_controller namespace so that our CustomActionControllerSubscriber# can provide its own instrumentation for certain events in the namespaceActionControllerSubscriber.detach\_from(:action\_controller)class CustomActionControllerSubscriber \< ActionControllerSubscriberattach\_to :action\_controller, inherit\_all: truedef start\_processing(event)info "A custom response to start\_processing events"end# =\> CustomActionControllerSubscriber will process events for "start\_processing.action\_controller" notifications# using its own #start\_processing implementation, while retaining ActionControllerSubscriber's instrumentation# for "redirect\_to.action\_controller" notificationsend
    

    Adrianna Chang

    👌 Allow the digest class used to generate non-sensitive digests to be configured with config.active_support.hash_digest_class.

    👌 config.active_support.use_sha1_digests is deprecated in favour of config.active_support.hash_digest_class = ::Digest::SHA1.

    Dirkjan Bussink

    Fix bug to make memcached write_entry expire correctly with unless_exist

    Jye Lee

    ➕ Add ActiveSupport::Duration conversion methods

    in_seconds, in_minutes, in_hours, in_days, in_weeks, in_months, and in_years return the respective duration covered.

    Jason York

    🛠 Fixed issue in ActiveSupport::Cache::RedisCacheStore not passing options
    to read_multi causing fetch_multi to not work properly

    Rajesh Sharma

    🛠 Fixed issue in ActiveSupport::Cache::MemCacheStore which caused duplicate compression,
    and caused the provided compression_threshold to not be respected.

    Max Gurewitz

    Prevent RedisCacheStore and MemCacheStore from performing compression
    when reading entries written with raw: true.

    Max Gurewitz

    🚚 URI.parser is deprecated and will be removed in Rails 6.2. Use
    0️⃣ URI::DEFAULT_PARSER instead.

    Jean Boussier

    require_dependency has been documented to be obsolete in :zeitwerk
    🗄 mode. The method is not deprecated as such (yet), but applications are
    encouraged to not use it.

    💎 In :zeitwerk mode, semantics match Ruby's and you do not need to be
    defensive with load order. Just refer to classes and modules normally. If
    the constant name is dynamic, camelize if needed, and constantize.

    Xavier Noria

    Add 3rd person aliases of Symbol#start_with? and Symbol#end_with?.

    :foo.starts\_with?("f") # =\> true:foo.ends\_with?("o")# =\> true
    

    Ryuta Kamizono

    ➕ Add override of unary plus for ActiveSupport::Duration.

    + 1.second is now identical to +1.second to prevent errors
    👀 where a seemingly innocent change of formatting leads to a change in the code behavior.

    Before:

    +1.second.class# =\> ActiveSupport::Duration(+ 1.second).class# =\> Integer
    

    After:

    +1.second.class# =\> ActiveSupport::Duration(+ 1.second).class# =\> ActiveSupport::Duration
    

    🛠 Fixes #39079.

    Roman Kushnir

    ➕ Add subsec to ActiveSupport::TimeWithZone#inspect.

    Before:

    Time.at(1498099140).in_time_zone.inspect
    # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
    Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
    # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
    Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
    # => "Thu, 22 Jun 2017 02:39:00 UTC +00:00"
    

    After:

    Time.at(1498099140).in_time_zone.inspect
    # => "Thu, 22 Jun 2017 02:39:00.000000000 UTC +00:00"
    Time.at(1498099140, 123456780, :nsec).in_time_zone.inspect
    # => "Thu, 22 Jun 2017 02:39:00.123456780 UTC +00:00"
    Time.at(1498099140 + Rational("1/3")).in_time_zone.inspect
    # => "Thu, 22 Jun 2017 02:39:00.333333333 UTC +00:00"
    

    akinomaeni

    👍 Calling ActiveSupport::TaggedLogging#tagged without a block now returns a tagged logger.

    logger.tagged("BCX").info("Funky time!") # =\> [BCX] Funky time!
    

    Eugene Kenny

    💎 Align Range#cover? extension behavior with Ruby behavior for backwards ranges.

    💎 (1..10).cover?(5..3) now returns false, as it does in plain Ruby.

    ⚡️ Also update #include? and #=== behavior to match.

    Michael Groeneman

    ⚡️ Update to TZInfo v2.0.0.

    This changes the output of ActiveSupport::TimeZone.utc_to_local, but
    can be controlled with the
    ActiveSupport.utc_to_local_returns_utc_offset_times config.

    🆕 New Rails 6.1 apps have it enabled by default, existing apps can upgrade
    via the config in config/initializers/new_framework_defaults_6_1.rb

    See the utc_to_local_returns_utc_offset_times documentation for details.

    Phil Ross, Jared Beck

    ➕ Add Date and Time #yesterday? and #tomorrow? alongside #today?.

    Aliased to #prev_day? and #next_day? to match the existing #prev/next_day methods.

    Jatin Dhankhar

    ➕ Add Enumerable#pick to complement ActiveRecord::Relation#pick.

    Eugene Kenny

    [Breaking change] ActiveSupport::Callbacks#halted_callback_hook now receive a 2nd argument:

    ActiveSupport::Callbacks#halted_callback_hook now receive the name of the callback
    being halted as second argument.
    This change will allow you to differentiate which callbacks halted the chain
    and act accordingly.

    class Book \< ApplicationRecordbefore\_save { throw(:abort) }before\_create { throw(:abort) }def halted\_callback\_hook(filter, callback\_name)Rails.logger.info("Book couldn't be #{callback\_name}d")endBook.create # =\> "Book couldn't be created"book.save # =\> "Book couldn't be saved"end
    

    Edouard Chin

    👌 Support prepend with ActiveSupport::Concern.

    👍 Allows a module with extend ActiveSupport::Concern to be prepended.

    module Imposter
      extend ActiveSupport::Concern
    
      # Same as `included`, except only run when prepended.
      prepended do
      end
    end
    
    class Person
      prepend Imposter
    end
    

    Class methods are prepended to the base class, concerning is also
    ⚡️ updated: concerning :Imposter, prepend: true do.

    Jason Karns, Elia Schito

    🗄 Deprecate using Range#include? method to check the inclusion of a value
    in a date time range. It is recommended to use Range#cover? method
    instead of Range#include? to check the inclusion of a value
    in a date time range.

    Vishal Telangre

    👌 Support added for a round_mode parameter, in all number helpers. (See: BigDecimal::mode.)

    number\_to\_currency(1234567890.50, precision: 0, round\_mode: :half\_down) # =\> "$1,234,567,890"number\_to\_percentage(302.24398923423, precision: 5, round\_mode: :down) # =\> "302.24398%"number\_to\_rounded(389.32314, precision: 0, round\_mode: :ceil) # =\> "390"number\_to\_human\_size(483989, precision: 2, round\_mode: :up) # =\> "480 KB"number\_to\_human(489939, precision: 2, round\_mode: :floor) # =\> "480 Thousand"485000.to\_s(:human, precision: 2, round\_mode: :half\_even) # =\> "480 Thousand"
    

    Tom Lord

    Array#to_sentence no longer returns a frozen string.

    Before:

    ['one', 'two'].to_sentence.frozen?
    # => true
    

    After:

    ['one', 'two'].to_sentence.frozen?
    # => false
    

    Nicolas Dular

    👍 When an instance of ActiveSupport::Duration is converted to an iso8601 duration string, if weeks are mixed with date parts, the week part will be converted to days.
    📜 This keeps the parser and serializer on the same page.

    duration = ActiveSupport::Duration.build(1000000)# 1 week, 4 days, 13 hours, 46 minutes, and 40.0 secondsduration\_iso = duration.iso8601# P11DT13H46M40SActiveSupport::Duration.parse(duration\_iso)# 11 days, 13 hours, 46 minutes, and 40 secondsduration = ActiveSupport::Duration.build(604800)# 1 weekduration\_iso = duration.iso8601# P1WActiveSupport::Duration.parse(duration\_iso)# 1 week
    

    Abhishek Sarkar

    ➕ Add block support to ActiveSupport::Testing::TimeHelpers#travel_back.

    Tim Masliuchenko

    📇 Update ActiveSupport::Messages::Metadata#fresh? to work for cookies with expiry set when
    ActiveSupport.parse_json_times = true.

    Christian Gregg

    👌 Support symbolic links for content_path in ActiveSupport::EncryptedFile.

    Takumi Shotoku

    👌 Improve Range#===, Range#include?, and Range#cover? to work with beginless (startless)
    and endless range targets.

    Allen Hsu, Andrew Hodgkinson

    Don't use Process#clock_gettime(CLOCK_THREAD_CPUTIME_ID) on Solaris.

    Iain Beeston

    🏗 Prevent ActiveSupport::Duration.build(value) from creating instances of
    👍 ActiveSupport::Duration unless value is of type Numeric.

    ➕ Addresses the errant set of behaviours described in #37012 where
    👍 ActiveSupport::Duration comparisons would fail confusingly
    or return unexpected results when comparing durations built from instances of String.

    Before:

    small_duration_from_string = ActiveSupport::Duration.build('9')
    large_duration_from_string = ActiveSupport::Duration.build('100000000000000')
    small_duration_from_int = ActiveSupport::Duration.build(9)
    
    large_duration_from_string > small_duration_from_string
    # => false
    
    small_duration_from_string == small_duration_from_int
    # => false
    
    small_duration_from_int < large_duration_from_string
    # => ArgumentError (comparison of ActiveSupport::Duration::Scalar with ActiveSupport::Duration failed)
    
    large_duration_from_string > small_duration_from_int
    # => ArgumentError (comparison of String with ActiveSupport::Duration failed)
    

    After:

    small_duration_from_string = ActiveSupport::Duration.build('9')
    # => TypeError (can't build an ActiveSupport::Duration from a String)
    

    Alexei Emam

    ➕ Add ActiveSupport::Cache::Store#delete_multi method to delete multiple keys from the cache store.

    Peter Zhu

    👌 Support multiple arguments in HashWithIndifferentAccess for merge and update methods, to
    💎 follow Ruby 2.6 addition.

    Wojciech Wnętrzak

    Allow initializing thread_mattr_* attributes via :default option.

    class Scraper
      thread_mattr_reader :client, default: Api::Client.new
    end
    

    Guilherme Mansur

    ➕ Add compact_blank for those times when you want to remove #blank? values from
    an Enumerable (also compact_blank! on Hash, Array, ActionController::Parameters).

    Dana Sherson

    👉 Make ActiveSupport::Logger Fiber-safe.

    Use Fiber.current. __id__ in ActiveSupport::Logger#local_level= in order
    💎 to make log level local to Ruby Fibers in addition to Threads.

    Example:

    logger = ActiveSupport::Logger.new(STDOUT)
    logger.level = 1
    puts "Main is debug? #{logger.debug?}"
    
    Fiber.new {
      logger.local_level = 0
      puts "Thread is debug? #{logger.debug?}"
    }.resume
    
    puts "Main is debug? #{logger.debug?}"
    

    Before:

    Main is debug? false
    Thread is debug? true
    Main is debug? true
    

    After:

    Main is debug? false
    Thread is debug? true
    Main is debug? false
    

    🛠 Fixes #36752.

    Alexander Varnin

    👍 Allow the on_rotation proc used when decrypting/verifying a message to be
    passed at the constructor level.

    Before:

    crypt = ActiveSupport::MessageEncryptor.new('long_secret')
    crypt.decrypt_and_verify(encrypted_message, on_rotation: proc { ... })
    crypt.decrypt_and_verify(another_encrypted_message, on_rotation: proc { ... })
    

    After:

    crypt = ActiveSupport::MessageEncryptor.new('long_secret', on_rotation: proc { ... })
    crypt.decrypt_and_verify(encrypted_message)
    crypt.decrypt_and_verify(another_encrypted_message)
    

    Edouard Chin

    delegate_missing_to would raise a DelegationError if the object
    delegated to was nil. Now the allow_nil option has been added to enable
    the user to specify they want nil returned in this case.

    Matthew Tanous

    truncate would return the original string if it was too short to be truncated
    and a frozen string if it were long enough to be truncated. Now truncate will
    consistently return an unfrozen string regardless. This behavior is consistent
    with gsub and strip.

    Before:

    'foobar'.truncate(5).frozen?
    # => true
    'foobar'.truncate(6).frozen?
    # => false
    

    After:

    'foobar'.truncate(5).frozen?
    # => false
    'foobar'.truncate(6).frozen?
    # => false
    

    Jordan Thomas

    Active Model

    Pass in base instead of base_class to Error.human_attribute_name

    This is useful in cases where the human_attribute_name method depends
    on other attributes' values of the class under validation to derive what the
    attribute name should be.

    Filipe Sabella

    🗄 Deprecate marshalling load from legacy attributes format.

    Ryuta Kamizono

    *_previously_changed? accepts :from and :to keyword arguments like *_changed?.

    topic.update!(status: :archived)
    topic.status_previously_changed?(from: "active", to: "archived")
    # => true
    

    George Claghorn

    Raise FrozenError when trying to write attributes that aren't backed by the database on an object that is frozen:

    class Animal
      include ActiveModel::Attributes
      attribute :age
    end
    
    animal = Animal.new
    animal.freeze
    animal.age = 25 # => FrozenError, "can't modify a frozen Animal"
    

    Josh Brody

    Add *_previously_was attribute methods when dirty tracking. Example:

    pirate.update(catchphrase: "Ahoy!")
    pirate.previous_changes["catchphrase"] # => ["Thar She Blows!", "Ahoy!"]
    pirate.catchphrase_previously_was # => "Thar She Blows!"
    

    DHH

    Encapsulate each validation error as an Error object.

    The ActiveModel’s errors collection is now an array of these Error
    objects, instead of messages/details hash.

    For each of these Error object, its message and full_message methods
    are for generating error messages. Its details method would return error’s
    extra parameters, found in the original details hash.

    The change tries its best at maintaining backward compatibility, however
    some edge cases won’t be covered, like errors#first will return ActiveModel::Error and manipulating
    errors.messages and errors.details hashes directly will have no effect. Moving forward,
    please convert those direct manipulations to use provided API methods instead.

    🚀 The list of deprecated methods and their planned future behavioral changes at the next major release are:

    • errors#slice! will be removed.
    • errors#each with the key, value two-arguments block will stop working, while the error single-argument block would return Error object.
    • errors#values will be removed.
    • errors#keys will be removed.
    • errors#to_xml will be removed.
    • errors#to_h will be removed, and can be replaced with errors#to_hash.
    • Manipulating errors itself as a hash will have no effect (e.g. errors[:foo] = 'bar').
    • Manipulating the hash returned by errors#messages (e.g. errors.messages[:foo] = 'bar') will have no effect.
    • Manipulating the hash returned by errors#details (e.g. errors.details[:foo].clear) will have no effect.

    lulalala

    Active Record

    Only warn about negative enums if a positive form that would cause conflicts exists.

    🛠 Fixes #39065.

    Alex Ghiculescu

    Change attribute_for_inspect to take filter_attributes in consideration.

    Rafael Mendonça França

    Fix odd behavior of inverse_of with multiple belongs_to to same class.

    🛠 Fixes #35204.

    Tomoyuki Kai

    🏗 Build predicate conditions with objects that delegate #id and primary key:

    class AdminAuthordelegate\_missing\_to :@authordef initialize(author)@author = authorendendPost.where(author: AdminAuthor.new(author))
    

    Sean Doyle

    Add connected_to_many API.

    This API allows applications to connect to multiple databases at once without switching all of them or implementing a deeply nested stack.

    Before:

    AnimalsRecord.connected_to(role: :reading) do
    MealsRecord.connected_to(role: :reading) do
    Dog.first # read from animals replica
    Dinner.first # read from meals replica
    Person.first # read from primary writer
    end
    end

    After:

    ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
    Dog.first # read from animals replica
    Dinner.first # read from meals replica
    Person.first # read from primary writer
    end

    Eileen M. Uchitelle, John Crepezzi

    ➕ Add option to raise or log for ActiveRecord::StrictLoadingViolationError.

    ✅ Some applications may not want to raise an error in production if using strict_loading. This would allow an application to set strict loading to log for the production environment while still raising in development and test environments.

    Set config.active_record.action_on_strict_loading_violation to :log errors instead of raising.

    Eileen M. Uchitelle

    👍 Allow the inverse of a has_one association that was previously autosaved to be loaded.

    🛠 Fixes #34255.

    Steven Weber

    Optimise the length of index names for polymorphic references by using the reference name rather than the type and id column names.

    0️⃣ Because the default behaviour when adding an index with multiple columns is to use all column names in the index name, this could frequently lead to overly long index names for polymorphic references which would fail the migration if it exceeded the database limit.

    This change reduces the chance of that happening by using the reference name, e.g. index_my_table_on_my_reference.

    🛠 Fixes #38655.

    Luke Redpath

    0️⃣ MySQL: Uniqueness validator now respects default database collation,
    0️⃣ no longer enforce case sensitive comparison by default.

    Ryuta Kamizono

    ✂ 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

    Rafael Mendonça França

    Remove deprecated ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?.

    Rafael Mendonça França

    Remove deprecated ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?.

    Rafael Mendonça França

    ✂ Remove deprecated ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?.

    Rafael Mendonça França

    ⚡️ Remove deprecated ActiveRecord::Base#update_attributes and ActiveRecord::Base#update_attributes!.

    Rafael Mendonça França

    Remove deprecated migrations_path argument in ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version.

    Rafael Mendonça França

    Remove deprecated config.active_record.sqlite3.represent_boolean_as_integer.

    Rafael Mendonça França

    relation.create does no longer leak scope to class level querying methods
    in initialization block and callbacks.

    Before:

    User.where(name: "John").create do |john|
      User.find_by(name: "David") # => nil
    end
    

    After:

    User.where(name: "John").create do |john|
      User.find_by(name: "David") # => #<User name: "David", ...>
    end
    

    Ryuta Kamizono

    Named scope chain does no longer leak scope to class level querying methods.

    class User < ActiveRecord::Base
      scope :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'
    

    Ryuta Kamizono

    ✂ Remove deprecated methods from ActiveRecord::DatabaseConfigurations.

    fetch
    each
    first
    values
    []=

    Rafael Mendonça França

    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')
    

    Rafael Mendonça França

    ✂ Remove deprecated ActiveRecord::Result#to_hash method.

    Rafael Mendonça França

    Deprecate ActiveRecord::Base.allow_unsafe_raw_sql.

    Rafael Mendonça França

    ✂ Remove deprecated support for using unsafe raw SQL in ActiveRecord::Relation methods.

    Rafael Mendonça França

    👍 Allow users to silence the "Rails couldn't infer whether you are using multiple databases..."
    message using config.active_record.suppress_multiple_database_warning.

    Omri Gabay

    Connections can be granularly switched for abstract classes when connected_to is called.

    This change allows connected_to to switch a role and/or shard for a single abstract class instead of all classes globally. Applications that want to use the new feature need to set config.active_record.legacy_connection_handling to false in their application configuration.

    Example usage:

    0️⃣ Given an application we have a User model that inherits from ApplicationRecord and a Dog model that inherits from AnimalsRecord. AnimalsRecord and ApplicationRecord have writing and reading connections as well as shard default, one, and two.

    ActiveRecord::Base.connected\_to(role: :reading) doUser.first # reads from default replicaDog.first # reads from default replicaAnimalsRecord.connected\_to(role: :writing, shard: :one) doUser.first # reads from default replicaDog.first # reads from shard one primaryendUser.first # reads from default replicaDog.first # reads from default replicaApplicationRecord.connected\_to(role: :writing, shard: :two) doUser.first # reads from shard two primaryDog.first # reads from default replicaendend
    

    Eileen M. Uchitelle, John Crepezzi

    👍 Allow double-dash comment syntax when querying read-only databases

    James Adam

    ➕ Add values_at method.

    Returns an array containing the values associated with the given methods.

    topic = Topic.firsttopic.values\_at(:title, :author\_name)# =\> ["Budget", "Jason"]
    

    Similar to Hash#values_at but on an Active Record instance.

    Guillaume Briday

    Fix read_attribute_before_type_cast to consider attribute aliases.

    Marcelo Lauxen

    👌 Support passing record to uniqueness validator :conditions callable:

    class Article \< ApplicationRecordvalidates\_uniqueness\_of :title, conditions: -\>(article) {published\_at = article.published\_atwhere(published\_at: published\_at.beginning\_of\_year..published\_at.end\_of\_year)}end
    

    Eliot Sykes

    BatchEnumerator#update_all and BatchEnumerator#delete_all now return the
    total number of rows affected, just like their non-batched counterparts.

    Person.in\_batches.update\_all("first\_name = 'Eugene'") # =\> 42Person.in\_batches.delete\_all # =\> 42
    

    🛠 Fixes #40287.

    Eugene Kenny

    ➕ Add support for PostgreSQL interval data type with conversion to
    👍 ActiveSupport::Duration when loading records from database and
    serialization to ISO 8601 formatted duration string on save.
    ➕ Add support to define a column in migrations and get it in a schema dump.
    👍 Optional column precision is supported.

    To use this in 6.1, you need to place the next string to your model file:

    attribute :duration, :interval
    

    🚀 To keep old behavior until 6.2 is released:

    attribute :duration, :string
    

    Example:

    create_table :events do |t|
      t.string :name
      t.interval :duration
    end
    
    class Event < ApplicationRecord
      attribute :duration, :interval
    end
    
    Event.create!(name: 'Rock Fest', duration: 2.days)
    Event.last.duration # => 2 days
    Event.last.duration.iso8601 # => "P2D"
    Event.new(duration: 'P1DT12H3S').duration # => 1 day, 12 hours, and 3 seconds
    Event.new(duration: '1 day') # Unknown value will be ignored and NULL will be written to database
    

    Andrey Novikov

    👍 Allow associations supporting the dependent: key to take dependent: :destroy_async.

    class Account \< ActiveRecord::Basebelongs\_to :supplier, dependent: :destroy\_asyncend
    

    👷 :destroy_async will enqueue a job to destroy associated records in the background.

    DHH, George Claghorn, Cory Gwin, Rafael Mendonça França, Adrianna Chang

    ✅ Add SKIP_TEST_DATABASE environment variable to disable modifying the test database when rails db:create and rails db:drop are called.

    Jason Schweier

    connects_to can only be called on ActiveRecord::Base or abstract classes.

    Ensure that connects_to can only be called from ActiveRecord::Base or abstract classes. This protects the application from opening duplicate or too many connections.

    Eileen M. Uchitelle, John Crepezzi

    ✅ All connection adapters execute now raises ActiveRecord::ConnectionNotEstablished rather than
    ActiveRecord::StatementInvalid when they encounter a connection error.

    Jean Boussier

    Mysql2Adapter#quote_string now raises ActiveRecord::ConnectionNotEstablished rather than
    ActiveRecord::StatementInvalid when it can't connect to the MySQL server.

    Jean Boussier

    ➕ Add support for check constraints that are NOT VALID via validate: false (PostgreSQL-only).

    Alex Robbin

    🔧 Ensure the default configuration is considered primary or first for an environment

    🔧 If a multiple database application provides a configuration named primary, that will be treated as default. In applications that do not have a primary entry, the default database configuration will be the first configuration for an environment.

    Eileen M. Uchitelle

    👍 Allow where references association names as joined table name aliases.

    class Comment \< ActiveRecord::Baseenum label: [:default, :child]has\_many :children, class\_name: "Comment", foreign\_key: :parent\_idend# ... FROM comments LEFT OUTER JOIN comments children ON ... WHERE children.label = 1Comment.includes(:children).where("children.label": "child")
    

    Ryuta Kamizono

    👌 Support storing demodulized class name for polymorphic type.

    🚅 Before Rails 6.1, storing demodulized class name is supported only for STI type
    by store_full_sti_class class attribute.

    Now store_full_class_name class attribute can handle both STI and polymorphic types.

    Ryuta Kamizono

    🗄 Deprecate rails db:structure:{load, dump} tasks and extend
    💎 rails db:schema:{load, dump} tasks to work with either :ruby or :sql format,
    depending on config.active_record.schema_format configuration value.

    fatkodima

    Respect the select values for eager loading.

    post = Post.select("UPPER(title) AS title").firstpost.title # =\> "WELCOME TO THE WEBLOG"post.body# =\> ActiveModel::MissingAttributeError# Rails 6.0 (ignore the `select` values)post = Post.select("UPPER(title) AS title").eager\_load(:comments).firstpost.title # =\> "Welcome to the weblog"post.body# =\> "Such a lovely day"# Rails 6.1 (respect the `select` values)post = Post.select("UPPER(title) AS title").eager\_load(:comments).firstpost.title # =\> "WELCOME TO THE WEBLOG"post.body# =\> ActiveModel::MissingAttributeError
    

    Ryuta Kamizono

    👍 Allow attribute's default to be configured but keeping its own type.

    class Post \< ActiveRecord::Baseattribute :written\_at, default: -\> { Time.now.utc }end# Rails 6.0Post.type\_for\_attribute(:written\_at) # =\> #\<Type::Value ... precision: nil, ...\># Rails 6.1Post.type\_for\_attribute(:written\_at) # =\> #\<Type::DateTime ... precision: 6, ...\>
    

    Ryuta Kamizono

    👍 Allow default to be configured for Enum.

    class Book \< ActiveRecord::Baseenum status: [:proposed, :written, :published], \_default: :publishedendBook.new.status # =\> "published"
    

    Ryuta Kamizono

    🗄 Deprecate YAML loading from legacy format older than Rails 5.0.

    Ryuta Kamizono

    Added the setting ActiveRecord::Base.immutable_strings_by_default, which
    👍 allows you to specify that all string columns should be frozen unless
    otherwise specified. This will reduce memory pressure for applications which
    do not generally mutate string properties of Active Record objects.

    Sean Griffin, Ryuta Kamizono

    🗄 Deprecate map! and collect! on ActiveRecord::Result.

    Ryuta Kamizono

    👌 Support relation.and for intersection as Set theory.

    david\_and\_mary = Author.where(id: [david, mary])mary\_and\_bob= Author.where(id: [mary, bob])david\_and\_mary.merge(mary\_and\_bob) # =\> [mary, bob]david\_and\_mary.and(mary\_and\_bob) # =\> [mary]david\_and\_mary.or(mary\_and\_bob)# =\> [david, mary, bob]
    

    Ryuta Kamizono

    🔀 Merging conditions on the same column no longer maintain both conditions,
    🚅 and will be consistently replaced by the latter condition in Rails 6.2.
    🔀 To migrate to Rails 6.2's behavior, use relation.merge(other, rewhere: true).

    # Rails 6.1 (IN clause is replaced by merger side equality condition)Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # =\> [bob]# Rails 6.1 (both conflict conditions exists, deprecated)Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # =\> []# Rails 6.1 with rewhere to migrate to Rails 6.2's behaviorAuthor.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # =\> [bob]# Rails 6.2 (same behavior with IN clause, mergee side condition is consistently replaced)Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # =\> [bob]Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # =\> [bob]
    

    Ryuta Kamizono

    Do not mark Postgresql MAC address and UUID attributes as changed when the assigned value only varies by case.

    Peter Fry

    Resolve issue with insert_all unique_by option when used with expression index.

    When the :unique_by option of ActiveRecord::Persistence.insert_all and
    ActiveRecord::Persistence.upsert_all was used with the name of an expression index, an error
    was raised. Adding a guard around the formatting behavior for the :unique_by corrects this.

    Usage:

    create\_table :books, id: :integer, force: true do |t| t.column :name, :stringt.index "lower(name)", unique: trueendBook.insert\_all [{ name: "MyTest" }], unique\_by: :index\_books\_on\_lower\_name
    

    🛠 Fixes #39516.

    Austen Madden

    ➕ Add basic support for CHECK constraints to database migrations.

    Usage:

    add\_check\_constraint :products, "price \> 0", name: "price\_check"remove\_check\_constraint :products, name: "price\_check"
    

    fatkodima

    Add ActiveRecord::Base.strict_loading_by_default and ActiveRecord::Base.strict_loading_by_default=
    🔧 to enable/disable strict_loading mode by default for a model. The configuration's value is
    inheritable by subclasses, but they can override that value and it will not impact parent class.

    Usage:

    class Developer \< ApplicationRecordself.strict\_loading\_by\_default = truehas\_many :projectsenddev = Developer.firstdev.projects.first# =\> ActiveRecord::StrictLoadingViolationError Exception: Developer is marked as strict\_loading and Project cannot be lazily loaded.
    

    bogdanvlviv

    🗄 Deprecate passing an Active Record object to quote/type_cast directly.

    Ryuta Kamizono

    0️⃣ Default engine ENGINE=InnoDB is no longer dumped to make schema more agnostic.

    Before:

    create\_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4\_0900\_ai\_ci", force: :cascade do |t|end
    

    After:

    create\_table "accounts", charset: "utf8mb4", collation: "utf8mb4\_0900\_ai\_ci", force: :cascade do |t|end
    

    Ryuta Kamizono

    ➕ Added delegated type as an alternative to single-table inheritance for representing class hierarchies.
    👀 See ActiveRecord::DelegatedType for the full description.

    DHH

    🗄 Deprecate aggregations with group by duplicated fields.

    🚅 To migrate to Rails 6.2's behavior, use uniq!(:group) to deduplicate group fields.

    accounts = Account.group(:firm\_id)# duplicated group fields, deprecated.accounts.merge(accounts.where.not(credit\_limit: nil)).sum(:credit\_limit)# =\> {# [1, 1] =\> 50,# [2, 2] =\> 60# }# use `uniq!(:group)` to deduplicate group fields.accounts.merge(accounts.where.not(credit\_limit: nil)).uniq!(:group).sum(:credit\_limit)# =\> {# 1 =\> 50,# 2 =\> 60# }
    

    Ryuta Kamizono

    🗄 Deprecate duplicated query annotations.

    🚅 To migrate to Rails 6.2's behavior, use uniq!(:annotate) to deduplicate query annotations.

    accounts = Account.where(id: [1, 2]).annotate("david and mary")# duplicated annotations, deprecated.accounts.merge(accounts.rewhere(id: 3))# SELECT accounts.\* FROM accounts WHERE accounts.id = 3 /\* david and mary \*/ /\* david and mary \*/# use `uniq!(:annotate)` to deduplicate annotations.accounts.merge(accounts.rewhere(id: 3)).uniq!(:annotate)# SELECT accounts.\* FROM accounts WHERE accounts.id = 3 /\* david and mary \*/
    

    Ryuta Kamizono

    Resolve conflict between counter cache and optimistic locking.

    ⚡️ Bump an Active Record instance's lock version after updating its counter
    cache. This avoids raising an unnecessary ActiveRecord::StaleObjectError
    upon subsequent transactions by maintaining parity with the corresponding
    database record's lock_version column.

    🛠 Fixes #16449.

    Aaron Lipman

    👌 Support merging option :rewhere to allow mergee side condition to be replaced exactly.

    david\_and\_mary = Author.where(id: david.id..mary.id)# both conflict conditions existsdavid\_and\_mary.merge(Author.where(id: bob)) # =\> []# mergee side condition is replaced by rewheredavid\_and\_mary.merge(Author.rewhere(id: bob)) # =\> [bob]# mergee side condition is replaced by rewhere optiondavid\_and\_mary.merge(Author.where(id: bob), rewhere: true) # =\> [bob]
    

    Ryuta Kamizono

    ➕ Add support for finding records based on signed ids, which are tamper-proof, verified ids that can be
    set to expire and scoped with a purpose. This is particularly useful for things like password reset
    or email verification, where you want the bearer of the signed id to be able to interact with the
    underlying record, but usually only within a certain time period.

    signed\_id = User.first.signed\_id expires\_in: 15.minutes, purpose: :password\_resetUser.find\_signed signed\_id # =\> nil, since the purpose does not matchtravel 16.minutesUser.find\_signed signed\_id, purpose: :password\_reset # =\> nil, since the signed id has expiredtravel\_backUser.find\_signed signed\_id, purpose: :password\_reset # =\> User.firstUser.find\_signed! "bad data" # =\> ActiveSupport::MessageVerifier::InvalidSignature
    

    DHH

    👌 Support ALGORITHM = INSTANT DDL option for index operations on MySQL.

    Ryuta Kamizono

    🛠 Fix index creation to preserve index comment in bulk change table on MySQL.

    Ryuta Kamizono

    👍 Allow unscope to be aware of table name qualified values.

    It is possible to unscope only the column in the specified table.

    posts = Post.joins(:comments).group(:"posts.hidden")posts = posts.where("posts.hidden": false, "comments.hidden": false)posts.count# =\> { false =\> 10 }# unscope both hidden columnsposts.unscope(where: :hidden).count# =\> { false =\> 11, true =\> 1 }# unscope only comments.hidden columnposts.unscope(where: :"comments.hidden").count# =\> { false =\> 11 }
    

    Ryuta Kamizono, Slava Korolev

    🛠 Fix rewhere to truly overwrite collided where clause by new where clause.

    steve = Person.find\_by(name: "Steve")david = Author.find\_by(name: "David")relation = Essay.where(writer: steve)# Beforerelation.rewhere(writer: david).to\_a # =\> []# Afterrelation.rewhere(writer: david).to\_a # =\> [david]
    

    Ryuta Kamizono

    Inspect time attributes with subsec and time zone offset.

    p Knot.create=\> #\<Knot id: 1, created\_at: "2016-05-05 01:29:47.116928000 +0000"\>
    

    akinomaeni, Jonathan Hefner

    🗄 Deprecate passing a column to type_cast.

    Ryuta Kamizono

    Deprecate in_clause_length and allowed_index_name_length in DatabaseLimits.

    Ryuta Kamizono

    👌 Support bulk insert/upsert on relation to preserve scope values.

    Josef Šimánek, Ryuta Kamizono

    Preserve column comment value on changing column name on MySQL.

    Islam Taha

    ➕ Add support for if_exists option for removing an index.

    The remove_index method can take an if_exists option. If this is set to true an error won't be raised if the index doesn't exist.

    Eileen M. Uchitelle

    ✂ Remove ibm_db, informix, mssql, oracle, and oracle12 Arel visitors which are not used in the code base.

    Ryuta Kamizono

    Prevent build_association from touching a parent record if the record isn't persisted for has_one associations.

    🛠 Fixes #38219.

    Josh Brody

    Add support for if_not_exists option for adding index.

    The add_index method respects if_not_exists option. If it is set to true
    index won't be added.

    Usage:

    add\_index :users, :account\_id, if\_not\_exists: true
    

    The if_not_exists option passed to create_table also gets propagated to indexes
    created within that migration so that if table and its indexes exist then there is no
    attempt to create them again.

    Prathamesh Sonpatki

    🆕 Add ActiveRecord::Base#previously_new_record? to show if a record was new before the last save.

    Tom Ward

    Support descending order for find_each, find_in_batches, and in_batches.

    Batch processing methods allow you to work with the records in batches, greatly reducing memory consumption, but records are always batched from oldest id to newest.

    This change allows reversing the order, batching from newest to oldest. This is useful when you need to process newer batches of records first.

    0️⃣ Pass order: :desc to yield batches in descending order. The default remains order: :asc.

    Person.find\_each(order: :desc) do |person| person.party\_all\_night!end
    

    Alexey Vasiliev

    🛠 Fix insert_all with enum values.

    🛠 Fixes #38716.

    Joel Blum

    ➕ Add support for db:rollback:name for multiple database applications.

    ⏪ Multiple database applications will now raise if db:rollback is call and recommend using the db:rollback:[NAME] to rollback migrations.

    Eileen M. Uchitelle

    Relation#pick now uses already loaded results instead of making another query.

    Eugene Kenny

    🗄 Deprecate using return, break or throw to exit a transaction block after writes.

    Dylan Thacker-Smith

    Dump the schema or structure of a database when calling db:migrate:name.

    🚅 In previous versions of Rails, rails db:migrate would dump the schema of the database. In Rails 6, that holds true (rails db:migrate dumps all databases' schemas), but rails db:migrate:name does not share that behavior.

    🚅 Going forward, calls to rails db:migrate:name will dump the schema (or structure) of the database being migrated.

    Kyle Thompson

    🚅 Reset the ActiveRecord::Base connection after rails db:migrate:name.

    🔧 When rails db:migrate has finished, it ensures the ActiveRecord::Base connection is reset to its original configuration. Going forward, rails db:migrate:name will have the same behavior.

    Kyle Thompson

    Disallow calling connected_to on subclasses of ActiveRecord::Base.

    Behavior has not changed here but the previous API could be misleading to people who thought it would switch connections for only that class. connected_to switches the context from which we are getting connections, not the connections themselves.

    Eileen M. Uchitelle, John Crepezzi

    Add support for horizontal sharding to connects_to and connected_to.

    Applications can now connect to multiple shards and switch between their shards in an application. Note that the shard swapping is still a manual process as this change does not include an API for automatic shard swapping.

    Usage:

    🔧 Given the following configuration:

    # config/database.ymlproduction: primary: database: my\_databaseprimary\_shard\_one: database: my\_database\_shard\_one
    

    Connect to multiple shards:

    class ApplicationRecord \< ActiveRecord::Baseself.abstract\_class = trueconnects\_to shards: {default: { writing: :primary },shard\_one: { writing: :primary\_shard\_one }}
    

    Swap between shards in your controller / model code:

    ActiveRecord::Base.connected\_to(shard: :shard\_one) do# Read from shard oneend
    

    👀 The horizontal sharding API also supports read replicas. See guides for more details.

    Eileen M. Uchitelle, John Crepezzi

    🔧 Deprecate spec_name in favor of name on database configurations.

    The accessors for spec_name on configs_for and DatabaseConfig are deprecated. Please use name instead.

    🗄 Deprecated behavior:

    db\_config = ActiveRecord::Base.configs\_for(env\_name: "development", spec\_name: "primary")db\_config.spec\_name
    

    🆕 New behavior:

    db\_config = ActiveRecord::Base.configs\_for(env\_name: "development", name: "primary")db\_config.name
    

    Eileen M. Uchitelle

    ➕ Add additional database-specific rake tasks for multi-database users.

    🚅 Previously, rails db:create, rails db:drop, and rails db:migrate were the only rails tasks that could operate on a single
    database. For example:

    rails db:create
    rails db:create:primary
    rails db:create:animals
    rails db:drop
    rails db:drop:primary
    rails db:drop:animals
    rails db:migrate
    rails db:migrate:primary
    rails db:migrate:animals
    

    🚅 With these changes, rails db:schema:dump, rails db:schema:load, rails db:structure:dump, rails db:structure:load and
    rails db:test:prepare can additionally operate on a single database. For example:

    rails db:schema:dump
    rails db:schema:dump:primary
    rails db:schema:dump:animals
    rails db:schema:load
    rails db:schema:load:primary
    rails db:schema:load:animals
    rails db:structure:dump
    rails db:structure:dump:primary
    rails db:structure:dump:animals
    rails db:structure:load
    rails db:structure:load:primary
    rails db:structure:load:animals
    rails db:test:prepare
    rails db:test:prepare:primary
    rails db:test:prepare:animals
    

    Kyle Thompson

    ➕ Add support for strict_loading mode on association declarations.

    Raise an error if attempting to load a record from an association that has been marked as strict_loading unless it was explicitly eager loaded.

    Usage:

    class Developer \< ApplicationRecordhas\_many :projects, strict\_loading: trueenddev = Developer.firstdev.projects.first# =\> ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict\_loading and cannot be lazily loaded.
    

    Kevin Deisz

    ➕ Add support for strict_loading mode to prevent lazy loading of records.

    Raise an error if a parent record is marked as strict_loading and attempts to lazily load its associations. This is useful for finding places you may want to preload an association and avoid additional queries.

    Usage:

    dev = Developer.strict\_loading.firstdev.audit\_logs.to\_a# =\> ActiveRecord::StrictLoadingViolationError: Developer is marked as strict\_loading and AuditLog cannot be lazily loaded.
    

    Eileen M. Uchitelle, Aaron Patterson

    ➕ Add support for PostgreSQL 11+ partitioned indexes when using upsert_all.

    Sebastián Palma

    Adds support for if_not_exists to add_column and if_exists to remove_column.

    Applications can set their migrations to ignore exceptions raised when adding a column that already exists or when removing a column that does not exist.

    Example Usage:

    class AddColumnTitle \< ActiveRecord::Migration[6.1]def changeadd\_column :posts, :title, :string, if\_not\_exists: trueendend
    
    class RemoveColumnTitle \< ActiveRecord::Migration[6.1]def changeremove\_column :posts, :title, if\_exists: trueendend
    

    Eileen M. Uchitelle

    Regexp-escape table name for MS SQL Server.

    ➕ Add Regexp.escape to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like pluck and select fail in certain cases when used with the MS SQL Server adapter.

    Larry Reid

    Store advisory locks on their own named connection.

    🔒 Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.

    🔒 In order to fix this we are storing the advisory lock on a new connection with the connection specification name AdvisoryLockBase. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.

    Eileen M. Uchitelle, John Crepezzi

    👍 Allow schema cache path to be defined in the database configuration file.

    For example:

    development: adapter: postgresqldatabase: blog\_developmentpool: 5schema\_cache\_path: tmp/schema/main.yml
    

    Katrina Owen

    🚚 Deprecate #remove_connection in favor of #remove_connection_pool when called on the handler.

    🚚 #remove_connection is deprecated in order to support returning a DatabaseConfig object instead of a Hash. Use #remove_connection_pool, #remove_connection will be removed in 6.2.

    Eileen M. Uchitelle, John Crepezzi

    🔧 Deprecate #default_hash and it's alias #[] on database configurations.

    0️⃣ Applications should use configs_for. #default_hash and #[] will be removed in 6.2.

    Eileen M. Uchitelle, John Crepezzi

    ➕ Add scale support to ActiveRecord::Validations::NumericalityValidator.

    Gannon McGibbon

    Find orphans by looking for missing relations through chaining where.missing:

    Before:

    Post.left\_joins(:author).where(authors: { id: nil })
    

    After:

    Post.where.missing(:author)
    

    Tom Rossi

    Ensure :reading connections always raise if a write is attempted.

    🚅 Now Rails will raise an ActiveRecord::ReadOnlyError if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than :reading.

    Eileen M. Uchitelle

    Deprecate "primary" as the connection_specification_name for ActiveRecord::Base.

    "primary" has been deprecated as the connection_specification_name for ActiveRecord::Base in favor of using "ActiveRecord::Base". This change affects calls to ActiveRecord::Base.connection_handler.retrieve_connection and ActiveRecord::Base.connection_handler.remove_connection. If you're calling these methods with "primary", please switch to "ActiveRecord::Base".

    Eileen M. Uchitelle, John Crepezzi

    ➕ Add ActiveRecord::Validations::NumericalityValidator with
    👌 support for casting floats using a database columns' precision value.

    Gannon McGibbon

    Enforce fresh ETag header after a collection's contents change by adding
    ActiveRecord::Relation#cache_key_with_version. This method will be used by
    ActionController::ConditionalGet to ensure that when collection cache versioning
    is enabled, requests using ConditionalGet don't return the same ETag header
    after a collection is modified.

    🛠 Fixes #38078.

    Aaron Lipman

    ✅ Skip test database when running db:create or db:drop in development
    with DATABASE_URL set.

    Brian Buchalter

    🔧 Don't allow mutations on the database configurations hash.

    🔧 Freeze the configurations hash to disallow directly changing it. If applications need to change the hash, for example to create databases for parallelization, they should use the DatabaseConfig object directly.

    Before:

    @db\_config = ActiveRecord::Base.configurations.configs\_for(env\_name: "test", spec\_name: "primary")@db\_config.configuration\_hash.merge!(idle\_timeout: "0.02")
    

    After:

    @db\_config = ActiveRecord::Base.configurations.configs\_for(env\_name: "test", spec\_name: "primary")config = @db\_config.configuration\_hash.merge(idle\_timeout: "0.02")db\_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@db\_config.env\_name, @db\_config.spec\_name, config)
    

    Eileen M. Uchitelle, John Crepezzi

    Remove :connection_id from the sql.active_record notification.

    Aaron Patterson, Rafael Mendonça França

    The :name key will no longer be returned as part of DatabaseConfig#configuration_hash. Please use DatabaseConfig#owner_name instead.

    Eileen M. Uchitelle, John Crepezzi

    ActiveRecord's belongs_to_required_by_default flag can now be set per model.

    You can now opt-out/opt-in specific models from having their associations required
    0️⃣ by default.

    This change is meant to ease the process of migrating all your models to have
    their association required.

    Edouard Chin

    🗄 The connection_config method has been deprecated, please use connection_db_config instead which will return a DatabaseConfigurations::DatabaseConfig instead of a Hash.

    Eileen M. Uchitelle, John Crepezzi

    Retain explicit selections on the base model after applying includes and joins.

    🚅 Resolves #34889.

    Patrick Rebsch

    🗄 The database kwarg is deprecated without replacement because it can't be used for sharding and creates an issue if it's used during a request. Applications that need to create new connections should use connects_to instead.

    Eileen M. Uchitelle, John Crepezzi

    👍 Allow attributes to be fetched from Arel node groupings.

    Jeff Emminger, Gannon McGibbon

    👍 A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgreSQL options.

    Joshua Flanagan

    Calling methods like establish_connection with a Hash which is invalid (eg: no adapter) will now raise an error the same way as connections defined in config/database.yml.

    John Crepezzi

    Specifying implicit_order_column now subsorts the records by primary key if available to ensure deterministic results.

    Paweł Urbanek

    where(attr => []) now loads an empty result without making a query.

    John Hawthorn

    🛠 Fixed the performance regression for primary_keys introduced MySQL 8.0.

    Hiroyuki Ishii

    Add support for belongs_to to has_many inversing.

    Gannon McGibbon

    Allow length configuration for has_secure_token method. The minimum length
    is set at 24 characters.

    Before:

    has\_secure\_token :auth\_token
    

    After:

    has\_secure\_token :default\_token# 24 charactershas\_secure\_token :auth\_token, length: 36# 36 charactershas\_secure\_token :invalid\_token, length: 12 # =\> ActiveRecord::SecureToken::MinimumLengthError
    

    Bernardo de Araujo

    🔧 Deprecate DatabaseConfigurations#to_h. These connection hashes are still available via ActiveRecord::Base.configurations.configs_for.

    Eileen Uchitelle, John Crepezzi

    ➕ Add DatabaseConfig#configuration_hash to return database configuration hashes with symbol keys, and use all symbol-key configuration hashes internally. Deprecate DatabaseConfig#config which returns a String-keyed Hash with the same values.

    John Crepezzi, Eileen Uchitelle

    👍 Allow column names to be passed to remove_index positionally along with other options.

    🚚 Passing other options can be necessary to make remove_index correctly reversible.

    Before:

    add_index :reports, :report_id # => works
    add_index :reports, :report_id, unique: true # => works
    remove_index :reports, :report_id # => works
    remove_index :reports, :report_id, unique: true # => ArgumentError
    

    After:

    remove_index :reports, :report_id, unique: true # => works
    

    Eugene Kenny

    👍 Allow bulk ALTER statements to drop and recreate indexes with the same name.

    Eugene Kenny

    insert, insert_all, upsert, and upsert_all now clear the query cache.

    Eugene Kenny

    Call while_preventing_writes directly from connected_to.

    In some cases application authors want to use the database switching middleware and make explicit calls with connected_to. It's possible for an app to turn off writes and not turn them back on by the time we call connected_to(role: :writing).

    This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.

    Eileen M. Uchitelle

    👌 Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.

    Kir Shatrov

    Stop trying to read yaml file fixtures when loading Active Record fixtures.

    Gannon McGibbon

    🗄 Deprecate .reorder(nil) with .first / .first! taking non-deterministic result.

    To continue taking non-deterministic result, use .take / .take! instead.

    Ryuta Kamizono

    Preserve user supplied joins order as much as possible.

    🛠 Fixes #36761, #34328, #24281, #12953.

    Ryuta Kamizono

    Allow matches_regex and does_not_match_regexp on the MySQL Arel visitor.

    James Pearson

    👍 Allow specifying fixtures to be ignored by setting ignore in YAML file's '_fixture' section.

    Tongfei Gao

    👉 Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.

    John Crepezzi, Eileen Uchitelle

    ➕ Add a warning for enum elements with 'not_' prefix.

    class Foo
      enum status: [:sent, :not_sent]
    end
    

    Edu Depetris

    👉 Make currency symbols optional for money column type in PostgreSQL.

    Joel Schneider

    ➕ Add support for beginless ranges, introduced in Ruby 2.7.

    Josh Goodall

    ➕ Add database_exists? method to connection adapters to check if a database exists.

    Guilherme Mansur

    Loading the schema for a model that has no table_name raises a TableNotSpecified error.

    Guilherme Mansur, Eugene Kenny

    PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.

    🛠 Fixes #36022.

    Ryuta Kamizono

    👉 Make ActiveRecord ConnectionPool.connections method thread-safe.

    🛠 Fixes #36465.

    Jeff Doering

    Add support for multiple databases to rails db:abort_if_pending_migrations.

    Mark Lee

    🛠 Fix sqlite3 collation parsing when using decimal columns.

    Martin R. Schuster

    🛠 Fix invalid schema when primary key column has a comment.

    🛠 Fixes #29966.

    Guilherme Goettems Schneider

    🛠 Fix table comment also being applied to the primary key column.

    Guilherme Goettems Schneider

    👍 Allow generated create_table migrations to include or skip timestamps.

    Michael Duchemin

    Action View

    👍 SanitizeHelper.sanitized_allowed_attributes and SanitizeHelper.sanitized_allowed_tags
    call safe_list_sanitizer's class method

    🛠 Fixes #39586

    Taufiq Muhammadi

    🔄 Change form_with to generate non-remote forms by default.

    0️⃣ form_with would generate a remote form by default. This would confuse
    👉 users because they were forced to handle remote requests.

    0️⃣ All new 6.1 applications will generate non-remote forms by default.
    ⬆️ When upgrading a 6.0 application you can enable remote forms by default by
    setting config.action_view.form_with_generates_remote_forms to true.

    Petrik de Heus

    Yield translated strings to calls of ActionView::FormBuilder#button
    when a block is given.

    Sean Doyle

    🌐 Alias ActionView::Helpers::Tags::Label::LabelBuilder#translation to
    #to_s so that form.label calls can yield that value to their blocks.

    Sean Doyle

    Rename the new TagHelper#class_names method to TagHelper#token_list,
    and make the original available as an alias.

    token_list("foo", "foo bar")
    # => "foo bar"
    

    Sean Doyle

    ARIA Array and Hash attributes are treated as space separated DOMTokenList
    values. This is useful when declaring lists of label text identifiers in
    aria-labelledby or aria-describedby.

    tag.input type: 'checkbox', name: 'published', aria: {
      invalid: @post.errors[:published].any?,
      labelledby: ['published_context', 'published_label'],
      describedby: { published_errors: @post.errors[:published].any? }
    }
    #=> <input
          type="checkbox" name="published" aria-invalid="true"
          aria-labelledby="published_context published_label"
          aria-describedby="published_errors"
        >
    

    Sean Doyle

    ✂ Remove deprecated escape_whitelist from ActionView::Template::Handlers::ERB.

    Rafael Mendonça França

    Remove deprecated find_all_anywhere from ActionView::Resolver.

    Rafael Mendonça França

    ✂ Remove deprecated formats from ActionView::Template::HTML.

    Rafael Mendonça França

    ✂ Remove deprecated formats from ActionView::Template::RawFile.

    Rafael Mendonça França

    ✂ Remove deprecated formats from ActionView::Template::Text.

    Rafael Mendonça França

    ✂ Remove deprecated find_file from ActionView::PathSet.

    Rafael Mendonça França

    ✂ Remove deprecated rendered_format from ActionView::LookupContext.

    Rafael Mendonça França

    ✂ Remove deprecated find_file from ActionView::ViewPaths.

    Rafael Mendonça França

    Require that ActionView::Base subclasses implement #compiled_method_container.

    Rafael Mendonça França

    ✂ Remove deprecated support to pass an object that is not a ActionView::LookupContext as the first argument
    in ActionView::Base#initialize.

    Rafael Mendonça França

    ✂ Remove deprecated format argument ActionView::Base#initialize.

    Rafael Mendonça França

    ✂ Remove deprecated ActionView::Template#refresh.

    Rafael Mendonça França

    ✂ Remove deprecated ActionView::Template#original_encoding.

    Rafael Mendonça França

    ✂ Remove deprecated ActionView::Template#variants.

    Rafael Mendonça França

    ✂ Remove deprecated ActionView::Template#formats.

    Rafael Mendonça França

    ✂ Remove deprecated ActionView::Template#virtual_path=.

    Rafael Mendonça França

    ✂ Remove deprecated ActionView::Template#updated_at.

    Rafael Mendonça França

    ✂ Remove deprecated updated_at argument required on ActionView::Template#initialize.

    Rafael Mendonça França

    👉 Make locals argument required on ActionView::Template#initialize.

    Rafael Mendonça França

    Remove deprecated ActionView::Template.finalize_compiled_template_methods.

    Rafael Mendonça França

    Remove deprecated config.action_view.finalize_compiled_template_methods

    Rafael Mendonça França

    ✂ Remove deprecated support to calling ActionView::ViewPaths#with_fallback with a block.

    Rafael Mendonça França

    ✂ Remove deprecated support to passing absolute paths to render template:.

    Rafael Mendonça França

    ✂ Remove deprecated support to passing relative paths to render file:.

    Rafael Mendonça França

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

    Rafael Mendonça França

    ✂ Remove deprecated pattern argument in ActionView::Template::PathResolver.

    Rafael Mendonça França

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

    Rafael Mendonça França

    🌐 ActionView::Helpers::TranslationHelper#translate accepts a block, yielding
    🌐 the translated text and the fully resolved translation key:

    <%= translate(".relative_key") do |translation, resolved_key| %>
      <span title="<%= resolved_key %>"><%= translation %></span>
    <% end %>
    

    Sean Doyle

    Ensure cache fragment digests include all relevant template dependencies when
    🚚 fragments are contained in a block passed to the render helper. Remove the
    virtual_path keyword arguments found in CacheHelper as they no longer possess
    🚅 any function following 1581cab.

    🛠 Fixes #38984.

    Aaron Lipman

    Deprecate config.action_view.raise_on_missing_translations in favor of
    config.i18n.raise_on_missing_translations.

    🆕 New generalized configuration option now determines whether an error should be raised
    🌐 for missing translations in controllers and views.

    fatkodima

    Instrument layout rendering in TemplateRenderer#render_with_layout as render_layout.action_view,
    🛰 and include (when necessary) the layout's virtual path in notification payloads for collection and partial renders.

    Zach Kemp

    ActionView::Base.annotate_rendered_view_with_filenames annotates HTML output with template file names.

    Joel Hawksley, Aaron Patterson

    🌐 ActionView::Helpers::TranslationHelper#translate returns nil when
    🌐 passed default: nil without a translation matching I18n#translate.

    Stefan Wrobel

    ⚡️ OptimizedFileSystemResolver prefers template details in order of locale,
    formats, variants, handlers.

    Iago Pimenta

    ➕ Added class_names helper to create a CSS class value with conditional classes.

    Joel Hawksley, Aaron Patterson

    ➕ Add support for conditional values to TagBuilder.

    Joel Hawksley

    ActionView::Helpers::FormOptionsHelper#select should mark option for nil as selected.

    @post = [email protected] = nil# Beforeselect("post", "category", none: nil, programming: 1, economics: 2)# =\># \<select name="post[category]" id="post\_category"\># \<option value=""\>none\</option\># \<option value="1"\>programming\</option\># \<option value="2"\>economics\</option\># \</select\># Afterselect("post", "category", none: nil, programming: 1, economics: 2)# =\># \<select name="post[category]" id="post\_category"\># \<option selected="selected" value=""\>none\</option\># \<option value="1"\>programming\</option\># \<option value="2"\>economics\</option\># \</select\>
    

    bogdanvlviv

    🌲 Log lines for partial renders and started template renders are now
    emitted at the DEBUG level instead of INFO.

    Completed template renders are still logged at the INFO level.

    DHH

    🚅 ActionView::Helpers::SanitizeHelper: support rails-html-sanitizer 1.1.0.

    Juanito Fatas

    ➕ Added phone_to helper method to create a link from mobile numbers.

    Pietro Moro

    annotated_source_code returns an empty array so TemplateErrors without a
    template in the backtrace are surfaced properly by DebugExceptions.

    Guilherme Mansur, Kasper Timm Hansen

    ➕ Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.

    Guilherme Mansur, Gannon McGibbon

    RenderingHelper supports rendering objects that respond_to? :render_in.

    Joel Hawksley, Natasha Umer, Aaron Patterson, Shawn Allen, Emily Plummer, Diana Mounter, John Hawthorn, Nathan Herald, Zaid Zawaideh, Zach Ahn

    🏷 Fix select_tag so that it doesn't change options when include_blank is present.

    Younes SERRAJ

    Action Pack

    👌 Support for the HTTP header Feature-Policy has been revised to reflect
    its rename to Permissions-Policy.

    Rails.application.config.permissions\_policy do |p| p.camera:nonep.gyroscope:nonep.microphone :nonep.usb:nonep.fullscreen :selfp.payment:self, "https://secure-example.com"end
    

    Julien Grillot

    👍 Allow ActionDispatch::HostAuthorization to exclude specific requests.

    Host Authorization checks can be skipped for specific requests. This allows for health check requests to be permitted for requests with missing or non-matching host headers.

    Chris Bisnett

    Add config.action_dispatch.request_id_header to allow changing the name of
    the unique X-Request-Id header

    Arlston Fernandes

    Deprecate config.action_dispatch.return_only_media_type_on_content_type.

    Rafael Mendonça França

    🔄 Change ActionDispatch::Response#content_type to return the full Content-Type header.

    Rafael Mendonça França

    ✂ Remove deprecated ActionDispatch::Http::ParameterFilter.

    Rafael Mendonça França

    ➕ Added support for exclusive no-store Cache-Control header.

    If no-store is set on Cache-Control header it is exclusive (all other cache directives are dropped).

    Chris Kruger

    Catch invalid UTF-8 parameters for POST requests and respond with BadRequest.

    Additionally, perform #set_binary_encoding in ActionDispatch::Http::Request#GET and
    ActionDispatch::Http::Request#POST prior to validating encoding.

    Adrianna Chang

    👍 Allow assert_recognizes routing assertions to work on mounted root routes.

    Gannon McGibbon

    🔄 Change default redirection status code for non-GET/HEAD requests to 308 Permanent Redirect for ActionDispatch::SSL.

    Alan Tan, Oz Ben-David

    🛠 Fix follow_redirect! to follow redirection with same HTTP verb when following
    a 308 redirection.

    Alan Tan

    When multiple domains are specified for a cookie, a domain will now be
    chosen only if it is equal to or is a superdomain of the request host.

    Jonathan Hefner

    ActionDispatch::Static handles precompiled Brotli (.br) files.

    ➕ Adds to existing support for precompiled gzip (.gz) files.
    👍 Brotli files are preferred due to much better compression.

    💻 When the browser requests /some.js with Accept-Encoding: br,
    we check for public/some.js.br and serve that file, if present, with
    Content-Encoding: br and Vary: Accept-Encoding headers.

    Ryan Edward Hall, Jeremy Daer

    Add raise_on_missing_translations support for controllers.

    🌐 This configuration determines whether an error should be raised for missing translations.
    It can be enabled through config.i18n.raise_on_missing_translations. Note that described
    🌐 configuration also affects raising error for missing translations in views.

    fatkodima

    ➕ Added compact and compact! to ActionController::Parameters.

    Eugene Kenny

    Calling each_pair or each_value on an ActionController::Parameters
    without passing a block now returns an enumerator.

    Eugene Kenny

    fixture_file_upload now uses path relative to file_fixture_path

    Previously the path had to be relative to fixture_path.
    You can change your existing code as follow:

    # Beforefixture\_file\_upload('files/dog.png')# Afterfixture\_file\_upload('dog.png')
    

    Edouard Chin

    ✂ Remove deprecated force_ssl at the controller level.

    Rafael Mendonça França

    The +helper+ class method for controllers loads helper modules specified as
    strings/symbols with String#constantize instead of require_dependency.

    👍 Remember that support for strings/symbols is only a convenient API. You can
    always pass a module object:

    helper UtilsHelper
    

    which is recommended because it is simple and direct. When a string/symbol
    is received, helper just manipulates and inflects the argument to obtain
    that same module object.

    Xavier Noria, Jean Boussier

    Correctly identify the entire localhost IPv4 range as trusted proxy.

    Nick Soracco

    0️⃣ url_for will now use "https://" as the default protocol when
    🚅 Rails.application.config.force_ssl is set to true.

    Jonathan Hefner

    0️⃣ Accept and default to base64_urlsafe CSRF tokens.

    Base64 strict-encoded CSRF tokens are not inherently websafe, which makes
    them difficult to deal with. For example, the common practice of sending
    💻 the CSRF token to a browser in a client-readable cookie does not work properly
    out of the box: the value has to be url-encoded and decoded to survive transport.

    Now, we generate Base64 urlsafe-encoded CSRF tokens, which are inherently safe
    to transport. Validation accepts both urlsafe tokens, and strict-encoded tokens
    for backwards compatibility.

    Scott Blum

    👌 Support rolling deploys for cookie serialization/encryption changes.

    ⚡️ In a distributed configuration like rolling update, users may observe
    🚀 both old and new instances during deployment. Users may be served by a
    🆕 new instance and then by an old instance.

    That means when the server changes cookies_serializer from :marshal
    to :hybrid or the server changes use_authenticated_cookie_encryption
    from false to true, users may lose their sessions if they access the
    🚀 server during deployment.

    ⬇️ We added fallbacks to downgrade the cookie format when necessary during
    🚀 deployment, ensuring compatibility on both old and new instances.

    Masaki Hara

    ActionDispatch::Request.remote_ip has ip address even when all sites are trusted.

    0️⃣ Before, if all X-Forwarded-For sites were trusted, the remote_ip would default to 127.0.0.1.
    Now, the furthest proxy site is used. e.g.: It now gives an ip address when using curl from the load balancer.

    Keenan Brock

    🛠 Fix possible information leak / session hijacking vulnerability.

    The ActionDispatch::Session::MemcacheStore is still vulnerable given it requires the
    ⚡️ gem dalli to be updated as well.

    CVE-2019-16782.

    ✅ Include child session assertion count in ActionDispatch::IntegrationTest.

    IntegrationTest#open_session uses dup to create the new session, which
    meant it had its own copy of @assertions. This prevented the assertions
    from being correctly counted and reported.

    Child sessions now have their attr_accessor overridden to delegate to the
    root session.

    🛠 Fixes #32142.

    Sam Bostock

    ➕ Add SameSite protection to every written cookie.

    Enabling SameSite cookie protection is an addition to CSRF protection,
    💻 where cookies won't be sent by browsers in cross-site POST requests when set to :lax.

    :strict disables cookies being sent in cross-site GET or POST requests.

    Passing :none disables this protection and is the same as previous versions albeit a ; SameSite=None is appended to the cookie.

    See upgrade instructions in config/initializers/new_framework_defaults_6_1.rb.

    More info here

    👍 NB: Technically already possible as Rack supports SameSite protection, this is to ensure it's applied to all cookies

    Cédric Fabianski

    Bring back the feature that allows loading external route files from the router.

    ⏪ This feature existed back in 2012 but got reverted with the incentive that
    🚅 https://github.com/rails/routing_concerns was a better approach. Turned out
    that this wasn't fully the case and loading external route files from the router
    can be helpful for applications with a really large set of routes.
    Without this feature, application needs to implement routes reloading
    themselves and it's not straightforward.

    # config/routes.rbRails.application.routes.draw dodraw(:admin)end# config/routes/admin.rbget :foo, to: 'foo#bar'
    

    Yehuda Katz, Edouard Chin

    🛠 Fix system test driver option initialization for non-headless browsers.

    glaszig

    redirect_to.action_controller notifications now include the ActionDispatch::Request in
    🛰 their payloads as :request.

    Austin Story

    respond_to#any no longer returns a response's Content-Type based on the
    request format but based on the block given.

    Example:

    def my\_actionrespond\_to do |format| format.any { render(json: { foo: 'bar' }) }endendget('my\_action.csv')
    

    The previous behaviour was to respond with a text/csv Content-Type which
    is inaccurate since a JSON response is being rendered.

    Now it correctly returns a application/json Content-Type.

    Edouard Chin

    Replaces (back)slashes in failure screenshot image paths with dashes.

    ✅ If a failed test case contained a slash or a backslash, a screenshot would be created in a
    nested directory, causing issues with tmp:clear.

    Damir Zekic

    ➕ Add params.member? to mimic Hash behavior.

    Younes Serraj

    process_action.action_controller notifications now include the following in their payloads:

    • :request - the ActionDispatch::Request
    • :response - the ActionDispatch::Response

    George Claghorn

    ⚡️ Updated ActionDispatch::Request.remote_ip setter to clear set the instance
    remote_ip to nil before setting the header that the value is derived
    from.

    🛠 Fixes #37383.

    Norm Provost

    🌲 ActionController::Base.log_at allows setting a different log level per request.

    # Use the debug level if a particular cookie is set.class ApplicationController \< ActionController::Baselog\_at :debug, if: -\> { cookies[:debug] }end
    

    George Claghorn

    👍 Allow system test screen shots to be taken more than once in
    ✅ a test by prefixing the file name with an incrementing counter.

    Add an environment variable RAILS_SYSTEM_TESTING_SCREENSHOT_HTML to
    enable saving of HTML during a screenshot in addition to the image.
    This uses the same image name, with the extension replaced with .html

    Tom Fakes

    ➕ Add Vary: Accept header when using Accept header for response.

    🚅 For some requests like /users/1, Rails uses requests' Accept
    header to determine what to return. And if we don't add Vary
    💻 in the response header, browsers might accidentally cache different
    types of content, which would cause issues: e.g. javascript got displayed
    🛠 instead of html content. This PR fixes these issues by adding Vary: Accept
    in these types of requests. For more detailed problem description, please read:

    🚅 #36213

    🛠 Fixes #25842.

    Stan Lo

    🛠 Fix IntegrationTest follow_redirect! to follow redirection using the same HTTP verb when following
    a 307 redirection.

    Edouard Chin

    ✅ System tests require Capybara 3.26 or newer.

    George Claghorn

    ⬇️ Reduced log noise handling ActionController::RoutingErrors.

    Alberto Fernández-Capel

    ➕ Add DSL for configuring HTTP Feature Policy.

    🔧 This new DSL provides a way to configure an HTTP Feature Policy at a
    global or per-controller level. Full details of HTTP Feature Policy
    specification and guidelines can be found at MDN:

    🌐 https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy

    Example global policy:

    Rails.application.config.feature\_policy do |f| f.camera:nonef.gyroscope:nonef.microphone:nonef.usb:nonef.fullscreen:selff.payment:self, "https://secure.example.com"end
    

    Example controller level policy:

    class PagesController \< ApplicationControllerfeature\_policy do |p| p.geolocation "https://example.com"endend
    

    Jacob Bednarz

    ➕ Add the ability to set the CSP nonce only to the specified directives.

    🛠 Fixes #35137.

    Yuji Yaginuma

    Keep part when scope option has value.

    When a route was defined within an optional scope, if that route didn't
    take parameters the scope was lost when using path helpers. This commit
    ensures scope is kept both when the route takes parameters or when it
    doesn't.

    🛠 Fixes #33219.

    Alberto Almagro

    Added deep_transform_keys and deep_transform_keys! methods to ActionController::Parameters.

    Gustavo Gutierrez

    Calling ActionController::Parameters#transform_keys/! without a block now returns
    an enumerator for the parameters instead of the underlying hash.

    Eugene Kenny

    🛠 Fix strong parameters blocks all attributes even when only some keys are invalid (non-numerical).
    It should only block invalid key's values instead.

    Stan Lo

    👷 Active Job

    Recover nano precision when serializing Time, TimeWithZone and DateTime objects.

    Alan Tan

    👷 Deprecate config.active_job.return_false_on_aborted_enqueue.

    Rafael Mendonça França

    👷 Return false when enqueuing a job is aborted.

    Rafael Mendonça França

    While using perform_enqueued_jobs test helper enqueued jobs must be stored for the later check with
    assert_enqueued_with.

    Dmitry Polushkin

    ActiveJob::TestCase#perform_enqueued_jobs without a block removes performed jobs from the queue.

    👷 That way the helper can be called multiple times and not perform a job invocation multiple times.

    def test\_jobsHelloJob.perform\_later("rafael")perform\_enqueued\_jobs # only runs with "rafael"HelloJob.perform\_later("david")perform\_enqueued\_jobs # only runs with "david"end
    

    Étienne Barrié

    ActiveJob::TestCase#perform_enqueued_jobs will no longer perform retries:

    When calling perform_enqueued_jobs without a block, the adapter will
    now perform jobs that are already in the queue. Jobs that will end up in
    the queue afterwards won't be performed.

    This change only affects perform_enqueued_jobs when no block is given.

    Edouard Chin

    ➕ Add queue name support to Que adapter.

    Brad Nauta, Wojciech Wnętrzak

    Don't run after_enqueue and after_perform callbacks if the callback chain is halted.

    class MyJob < ApplicationJob
      before_enqueue { throw(:abort) }
      after_enqueue { # won't enter here anymore }
    end
    

    after_enqueue and after_perform callbacks will no longer run if the callback chain is halted.
    🚅 This behaviour is a breaking change and won't take effect until Rails 6.2.
    🔧 To enable this behaviour in your app right now, you can add in your app's configuration file
    👷 config.active_job.skip_after_callbacks_if_terminated = true.

    Edouard Chin

    🛠 Fix enqueuing and performing incorrect logging message.

    👷 Jobs will no longer always log "Enqueued MyJob" or "Performed MyJob" when they actually didn't get enqueued/performed.

    class MyJob \< ApplicationJobbefore\_enqueue { throw(:abort) }endMyJob.perform\_later # Will no longer log "Enqueued MyJob" since job wasn't even enqueued through adapter.
    

    👷 A new message will be logged in case a job couldn't be enqueued, either because the callback chain was halted or
    👷 because an exception happened during enqueuing. (i.e. Redis is down when you try to enqueue your job)

    Edouard Chin

    ➕ Add an option to disable logging of the job arguments when enqueuing and executing the job.

    class SensitiveJob < ApplicationJob
      self.log_arguments = false
    
      def perform(my_sensitive_argument)
      end
    end
    

    🔧 When dealing with sensitive arguments as password and tokens it is now possible to configure the job
    🔊 to not put the sensitive argument in the logs.

    Rafael Mendonça França

    Changes in queue_name_prefix of a job no longer affects all other jobs.

    🛠 Fixes #37084.

    Lucas Mansur

    👍 Allow Class and Module instances to be serialized.

    Kevin Deisz

    Log potential matches in assert_enqueued_with and assert_performed_with.

    Gareth du Plooy

    Add at argument to the perform_enqueued_jobs test helper.

    John Crepezzi, Eileen Uchitelle

    assert_enqueued_with and assert_performed_with can now test jobs with relative delay.

    Vlado Cingel

    ➕ Add jitter to ActiveJob::Exceptions.retry_on.

    👷 ActiveJob::Exceptions.retry_on now uses a random amount of jitter in order to
    prevent the thundering herd effect. Defaults to
    15% (represented as 0.15) but overridable via the :jitter option when using retry_on.
    Jitter is applied when an Integer, ActiveSupport::Duration or :exponentially_longer, is passed to the wait argument in retry_on.

    retry\_on(MyError, wait: :exponentially\_longer, jitter: 0.30)
    

    Anthony Ross

    Action Mailer

    🔄 Change default queue name of the deliver (:mailers) job to be the job adapter's
    0️⃣ default (:default).

    Rafael Mendonça França

    ✂ Remove deprecated ActionMailer::Base.receive in favor of Action Mailbox.

    Rafael Mendonça França

    🛠 Fix ActionMailer assertions don't work for parameterized mail with legacy delivery job.

    bogdanvlviv

    ➕ Added email_address_with_name to properly escape addresses with names.

    Sunny Ripert

    Action Cable

    ActionCable::Connection::Base now allows intercepting unhandled exceptions
    with rescue_from before they are logged, which is useful for error reporting
    tools and other integrations.

    Justin Talbott

    Add ActionCable::Channel#stream_or_reject_for to stream if record is present, otherwise reject the connection

    Atul Bhosale

    Add ActionCable::Channel#stop_stream_from and #stop_stream_for to unsubscribe from a specific stream.

    Zhang Kang

    ➕ Add PostgreSQL subscription connection identificator.

    Now you can distinguish Action Cable PostgreSQL subscription connections among others.
    🔧 Also, you can set custom id in cable.yml configuration.

    SELECT application\_name FROM pg\_stat\_activity;/\* application\_name------------------------psqlActionCable-PID-42(2 rows)\*/
    

    Sergey Ponomarev

    Subscription confirmations and rejections are now logged at the DEBUG level instead of INFO.

    DHH

    Active Storage

    Change default queue name of the analysis (:active_storage_analysis) and
    purge (:active_storage_purge) jobs to be the job adapter's default (:default).

    Rafael Mendonça França

    Implement strict_loading on ActiveStorage associations.

    David Angulo

    ✂ Remove deprecated support to pass :combine_options operations to ActiveStorage::Transformers::ImageProcessing.

    Rafael Mendonça França

    ✂ Remove deprecated ActiveStorage::Transformers::MiniMagickTransformer.

    Rafael Mendonça França

    ✂ Remove deprecated config.active_storage.queue.

    Rafael Mendonça França

    ✂ Remove deprecated ActiveStorage::Downloading.

    Rafael Mendonça França

    ➕ Add per-environment configuration support

    Pietro Moro

    The Poppler PDF previewer renders a preview image using the original
    🖨 document's crop box rather than its media box, hiding print margins. This
    matches the behavior of the MuPDF previewer.

    Vincent Robert

    Touch parent model when an attachment is purged.

    Víctor Pérez Rodríguez

    Files can now be served by proxying them from the underlying storage service
    instead of redirecting to a signed service URL. Use the
    rails_storage_proxy_path and _url helpers to proxy an attached file:

    \<%= image\_tag rails\_storage\_proxy\_path(@user.avatar) %\>
    

    To proxy by default, set config.active_storage.resolve_model_to_route:

    # Proxy attached files instead.config.active\_storage.resolve\_model\_to\_route = :rails\_storage\_proxy
    
    \<%= image\_tag @user.avatar %\>
    

    0️⃣ To redirect to a signed service URL when the default file serving strategy
    is set to proxying, use the rails_storage_redirect_path and _url helpers:

    \<%= image\_tag rails\_storage\_redirect\_path(@user.avatar) %\>
    

    Jonathan Fleckenstein

    🌐 Add config.active_storage.web_image_content_types to allow applications
    to add content types (like image/webp) in which variants can be processed,
    instead of letting those images be converted to the fallback PNG format.

    Jeroen van Haperen

    ➕ Add support for creating variants of WebP images out of the box.

    Dino Maric

    👷 Only enqueue analysis jobs for blobs with non-null analyzer classes.

    Gannon McGibbon

    Previews are created on the same service as the original blob.

    Peter Zhu

    ✂ Remove unused disposition and content_type query parameters for DiskService.

    Peter Zhu

    👉 Use DiskController for both public and private files.

    DiskController is able to handle multiple services by adding a
    service_name field in the generated URL in DiskService.

    Peter Zhu

    Variants are tracked in the database to avoid existence checks in the storage service.

    George Claghorn

    🗄 Deprecate service_url methods in favour of url.

    Deprecate Variant#service_url and Preview#service_url to instead use
    #url method to be consistent with Blob.

    Peter Zhu

    Permanent URLs for public storage blobs.

    🔧 Services can be configured in config/storage.yml with a new key
    public: true | false to indicate whether a service holds public
    blobs or private blobs. Public services will always return a permanent URL.

    🗄 Deprecates Blob#service_url in favor of Blob#url.

    Peter Zhu

    🔧 Make services aware of configuration names.

    Gannon McGibbon

    The Content-Type header is set on image variants when they're uploaded to third-party storage services.

    Kyle Ribordy

    👍 Allow storage services to be configured per attachment.

    class User \< ActiveRecord::Basehas\_one\_attached :avatar, service: :s3endclass Gallery \< ActiveRecord::Basehas\_many\_attached :photos, service: :s3end
    

    Dmitry Tsepelev

    You can optionally provide a custom blob key when attaching a new file:

    user.avatar.attach key: "avatars/#{user.id}.jpg",io: io, content\_type: "image/jpeg", filename: "avatar.jpg"
    

    🔧 Active Storage will store the blob's data on the configured service at the provided key.

    George Claghorn

    Replace Blob.create_after_upload! with Blob.create_and_upload! and deprecate the former.

    create_after_upload! has been removed since it could lead to data
    corruption by uploading to a key on the storage service which happened to
    be already taken. Creating the record would then correctly raise a
    👻 database uniqueness exception but the stored object would already have
    overwritten another. create_and_upload! swaps the order of operations
    so that the key gets reserved up-front or the uniqueness error gets raised,
    before the upload to a key takes place.

    Julik Tarkhanov

    Set content disposition in direct upload using filename and disposition parameters to ActiveStorage::Service#headers_for_direct_upload.

    Peter Zhu

    👍 Allow record to be optionally passed to blob finders to make sharding
    easier.

    Gannon McGibbon

    Switch from azure-storage gem to azure-storage-blob gem for Azure service.

    Peter Zhu

    Add config.active_storage.draw_routes to disable Active Storage routes.

    Gannon McGibbon

    Image analysis is skipped if ImageMagick returns an error.

    📇 ActiveStorage::Analyzer::ImageAnalyzer#metadata would previously raise a
    👷 MiniMagick::Error, which caused persistent ActiveStorage::AnalyzeJob
    📇 failures. It now logs the error and returns {}, resulting in no metadata
    being added to the offending image blob.

    George Claghorn

    Method calls on singular attachments return nil when no file is attached.

    Previously, assuming the following User model, user.avatar.filename would
    raise a Module::DelegationError if no avatar was attached:

    class User \< ApplicationRecordhas\_one\_attached :avatarend
    

    They now return nil.

    Matthew Tanous

    👍 The mirror service supports direct uploads.

    🆕 New files are directly uploaded to the primary service. When a
    👷 directly-uploaded file is attached to a record, a background job is enqueued
    to copy it to each secondary service.

    🔧 Configure the queue used to process mirroring jobs by setting
    0️⃣ config.active_storage.queues.mirror. The default is :active_storage_mirror.

    George Claghorn

    The S3 service now permits uploading files larger than 5 gigabytes.

    When uploading a file greater than 100 megabytes in size, the service
    ✅ transparently switches to multipart uploads
    using a part size computed from the file's total size and S3's part count limit.

    No application changes are necessary to take advantage of this feature. You
    0️⃣ can customize the default 100 MB multipart upload threshold in your S3
    🔧 service's configuration:

    production: service: s3access\_key\_id: \<%= Rails.application.credentials.dig(:aws, :access\_key\_id) %\>secret\_access\_key: \<%= Rails.application.credentials.dig(:aws, :secret\_access\_key) %\>region: us-east-1bucket: my-bucketupload: multipart\_threshold: \<%= 250.megabytes %\>
    

    George Claghorn

    Action Mailbox

    Change default queue name of the incineration (:action_mailbox_incineration) and
    routing (:action_mailbox_routing) jobs to be the job adapter's default (:default).

    Rafael Mendonça França

    Sendgrid ingress now passes through the envelope recipient as X-Original-To.

    Mark Haussmann

    ⚡️ Update Mandrill inbound email route to respond appropriately to HEAD requests for URL health checks from Mandrill.

    Bill Cromie

    ➕ Add way to deliver emails via source instead of filling out a form through the conductor interface.

    DHH

    Mailgun ingress now passes through the envelope recipient as X-Original-To.

    Rikki Pitt

    Deprecate Rails.application.credentials.action_mailbox.api_key and MAILGUN_INGRESS_API_KEY in favor of Rails.application.credentials.action_mailbox.signing_key and MAILGUN_INGRESS_SIGNING_KEY.

    Matthijs Vos

    Allow easier creation of multi-part emails from the create_inbound_email_from_mail and receive_inbound_email_from_mail test helpers.

    Michael Herold

    Fix Bcc header not being included with emails from create_inbound_email_from test helpers.

    jduff

    ➕ Add ApplicationMailbox.mailbox_for to expose mailbox routing.

    James Dabbs

    Action Text

    Declare ActionText::FixtureSet.attachment to generate an
    <action-text-attachment sgid="..."></action-text-attachment> element with
    a valid sgid attribute.

    hello\_world\_review\_content: record: hello\_world (Review)name: contentbody: \<p\>\<%= ActionText::FixtureSet.attachment("messages", :hello\_world) %\> is great!\</p\>
    

    Sean Doyle

    Locate fill_in_rich_text_area by <label> text

    In addition to searching for <trix-editor> elements with the appropriate
    👍 aria-label attribute, also support locating elements that match the
    corresponding <label> element's text.

    Sean Doyle

    Be able to add a default value to rich_text_area.

    form.rich\_text\_area :content, value: "\<h1\>Hello world\</h1\>"#=\> \<input type="hidden" name="message[content]" id="message\_content\_trix\_input\_message\_1" value="\<h1\>Hello world\</h1\>"\>
    

    Paulo Ancheta

    ➕ Add method to confirm rich text content existence by adding ? after rich
    text attribute.

    message = Message.create!(body: "\<h1\>Funny times!\</h1\>")message.body? #=\> true
    

    Kyohei Toyoda

    The fill_in_rich_text_area system test helper locates a Trix editor
    and fills it in with the given HTML.

    # \<trix-editor id="message\_content" ...\>\</trix-editor\>fill\_in\_rich\_text\_area "message\_content", with: "Hello \<em\>world!\</em\>"# \<trix-editor placeholder="Your message here" ...\>\</trix-editor\>fill\_in\_rich\_text\_area "Your message here", with: "Hello \<em\>world!\</em\>"# \<trix-editor aria-label="Message content" ...\>\</trix-editor\>fill\_in\_rich\_text\_area "Message content", with: "Hello \<em\>world!\</em\>"# \<input id="trix\_input\_1" name="message[content]" type="hidden"\># \<trix-editor input="trix\_input\_1"\>\</trix-editor\>fill\_in\_rich\_text\_area "message[content]", with: "Hello \<em\>world!\</em\>"
    

    George Claghorn

    Railties

    ➕ Added Railtie#server hook called when Rails starts a server.
    This is useful in case your application or a library needs to run
    🚅 another process next to the Rails server. This is quite common in development
    for instance to run the Webpack or the React server.

    It can be used like this:

    class MyRailtie \< Rails::Railtieserver doWebpackServer.runendend
    

    Edouard Chin

    ✂ Remove deprecated rake dev:cache tasks.

    Rafael Mendonça França

    ✂ Remove deprecated rake routes tasks.

    Rafael Mendonça França

    ✂ Remove deprecated rake initializers tasks.

    Rafael Mendonça França

    ✂ Remove deprecated support for using the HOST environment variable to specify the server IP.

    Rafael Mendonça França

    ✂ Remove deprecated server argument from the rails server command.

    Rafael Mendonça França

    Remove deprecated SOURCE_ANNOTATION_DIRECTORIES environment variable support from rails notes.

    Rafael Mendonça França

    ✂ Remove deprecated connection option in the rails dbconsole command.

    Rafael Mendonça França

    ✂ Remove depreated rake notes tasks.

    Rafael Mendonça França

    Return a 405 Method Not Allowed response when a request uses an unknown HTTP method.

    🛠 Fixes #38998.

    Loren Norman

    🚅 Make railsrc file location xdg-specification compliant

    0️⃣ rails new will now look for the default railsrc file at
    $XDG_CONFIG_HOME/rails/railsrc (or ~/.config/rails/railsrc if
    XDG_CONFIG_HOME is not set). If this file does not exist, rails new
    🚅 will fall back to ~/.railsrc.

    The fallback behaviour means this does not cause any breaking changes.

    Nick Wolf

    🔄 Change the default logging level from :debug to :info to avoid inadvertent exposure of personally
    identifiable information (PII) in production environments.

    Eric M. Payne

    Automatically generate abstract class when using multiple databases.

    🔧 When generating a scaffold for a multiple database application, Rails will now automatically generate the abstract class for the database when the database argument is passed. This abstract class will include the connection information for the writing configuration and any models generated for that database will automatically inherit from the abstract class.

    Usage:

    $ bin/rails generate scaffold Pet name:string --database=animals
    

    Will create an abstract class for the animals connection.

    class AnimalsRecord \< ApplicationRecordself.abstract\_class = trueconnects\_to database: { writing: :animals }end
    

    And generate a Pet model that inherits from the new AnimalsRecord:

    class Pet \< AnimalsRecordend
    

    0️⃣ If you already have an abstract class and it follows a different pattern than Rails defaults, you can pass a parent class with the database argument.

    $ bin/rails generate scaffold Pet name:string --database=animals --parent=SecondaryBase
    

    This will ensure the model inherits from the SecondaryBase parent instead of AnimalsRecord

    class Pet \< SecondaryBaseend
    

    Eileen M. Uchitelle, John Crepezzi

    🚅 Accept params from url to prepopulate the Inbound Emails form in Rails conductor.

    Chris Oliver

    🚅 Create a new rails app using a minimal stack.

    🚅 rails new cool_app --minimal

    All the following are excluded from your minimal stack:

    • action_cable
    • action_mailbox
    • action_mailer
    • action_text
    • active_job
    • active_storage
    • bootsnap
    • jbuilder
    • spring
    • system_tests
    • turbolinks
    • webpack

    Haroon Ahmed, DHH

    ➕ Add default ENV variable option with BACKTRACE to turn off backtrace cleaning when debugging framework code in the
    generated config/initializers/backtrace_silencers.rb.

    🚅 BACKTRACE=1 ./bin/rails runner "MyClass.perform"

    DHH

    The autoloading guide for Zeitwerk mode documents how to autoload classes
    during application boot in a safe way.

    Haroon Ahmed, Xavier Noria

    🗄 The classic autoloader starts its deprecation cycle.

    ⬆️ New Rails projects are strongly discouraged from using classic, and we recommend that existing projects running on classic switch to zeitwerk mode when upgrading. Please check the Upgrading Ruby on Rails guide for tips.

    Xavier Noria

    ➕ Adds rails test:all for running all tests in the test directory.

    ✅ This runs all test files in the test directory, including system tests.

    Niklas Häusele

    ➕ Add config.generators.after_generate for processing to generated files.

    Register a callback that will get called right after generators has finished.

    Yuji Yaginuma

    🔧 Make test file patterns configurable via Environment variables

    🔧 This makes test file patterns configurable via two environment variables:
    🔧 DEFAULT_TEST, to configure files to test, and DEFAULT_TEST_EXCLUDE,
    🔧 to configure files to exclude from testing.

    These values were hardcoded before, which made it difficult to add
    🆕 new categories of tests that should not be executed by default (e.g:
    ✅ smoke tests).

    Jorge Manrubia

    🔌 No longer include rake rdoc task when generating plugins.

    📄 To generate docs, use the rdoc lib command instead.

    Jonathan Hefner

    👍 Allow relative paths with trailing slashes to be passed to rails test.

    Eugene Kenny

    ➕ Add rack-mini-profiler gem to the default Gemfile.

    🐎 rack-mini-profiler displays performance information such as SQL time and flame graphs.
    0️⃣ It's enabled by default in development environment, but can be enabled in production as well.
    👀 See the gem README for information on how to enable it in production.

    Osama Sayegh

    🚅 rails stats will now count TypeScript files toward JavaScript stats.

    Joshua Cody

    🔌 Run git init when generating plugins.

    Opt out with --skip-git.

    OKURA Masafumi

    ➕ Add benchmark generator.

    🚅 Introduce benchmark generator to benchmark Rails applications.

    🚅 rails generate benchmark opt_compare

    This creates a benchmark file that uses benchmark-ips.
    0️⃣ By default, two code blocks can be benchmarked using the before and after reports.

    You can run the generated benchmark file using:
    💎 ruby script/benchmarks/opt_compare.rb

    Kevin Jalbert, Gannon McGibbon

    ✅ Cache compiled view templates when running tests by default.

    When generating a new app without --skip-spring, caching classes is
    ✅ disabled in environments/test.rb. This implicitly disables caching
    view templates too. This change will enable view template caching by
    ➕ adding this to the generated environments/test.rb:

    config.action\_view.cache\_template\_loading = true
    

    Jorge Manrubia

    🚚 Introduce middleware move operations.

    With this change, you no longer need to delete and reinsert a middleware to
    🚚 move it from one place to another in the stack:

    config.middleware.move\_before ActionDispatch::Flash, Magical::Unicorns
    

    🚚 This will move the Magical::Unicorns middleware before
    🚚 ActionDispatch::Flash. You can also move it after with:

    config.middleware.move\_after ActionDispatch::Flash, Magical::Unicorns
    

    Genadi Samokovarov

    Generators that inherit from NamedBase respect --force option.

    Josh Brody

    👍 Allow configuration of eager_load behaviour for rake environment:

    config.rake_eager_load
    

    0️⃣ Defaults to false as per previous behaviour.

    Thierry Joyal

    🚅 Ensure Rails migration generator respects system-wide primary key config.

    🔧 When rails is configured to use a specific primary key type:

    config.generators do |g| g.orm :active\_record, primary\_key\_type: :uuidend
    

    Previously:

    $ bin/rails g migration add\_location\_to\_users location:references
    

    The references line in the migration would not have type: :uuid.
    This change causes the type to be applied appropriately.

    Louis-Michel Couture, Dermot Haughey

    🗄 Deprecate Rails::DBConsole#config.

    🔧 Rails::DBConsole#config is deprecated without replacement. Use Rails::DBConsole.db_config.configuration_hash instead.

    Eileen M. Uchitelle, John Crepezzi

    🔧 Rails.application.config_for merges shared configuration deeply.

    # config/example.ymlshared: foo: bar: baz: 1development: foo: bar: qux: 2
    
    # PreviouslyRails.application.config\_for(:example)[:foo][:bar] #=\> { qux: 2 }# NowRails.application.config\_for(:example)[:foo][:bar] #=\> { baz: 1, qux: 2 }
    

    Yuhei Kiriyama

    ✂ Remove access to values in nested hashes returned by Rails.application.config_for via String keys.

    # config/example.ymldevelopment: options: key: value
    
    Rails.application.config\_for(:example).options
    

    🗄 This used to return a Hash on which you could access values with String keys. This was deprecated in 6.0, and now doesn't work anymore.

    Étienne Barrié

    🔧 Configuration files for environments (config/environments/*.rb) are
    now able to modify autoload_paths, autoload_once_paths, and
    eager_load_paths.

    🔧 As a consequence, applications cannot autoload within those files. Before, they technically could, but changes in autoloaded classes or modules had no effect anyway in the configuration because reloading does not reboot.

    Ways to use application code in these files:

    🔧 Define early in the boot process a class that is not reloadable, from which the application takes configuration values that get passed to the framework.

    # In config/application.rb, for example.require "#{Rails.root}/lib/my\_app/config"# In config/environments/development.rb, for example.config.foo = MyApp::Config.foo
    

    🔧 If the class has to be reloadable, then wrap the configuration code in a to_prepare block:

    config.to\_prepare doconfig.foo = MyModel.fooend
    

    🔧 That assigns the latest MyModel.foo to config.foo when the application boots, and each time there is a reload. But whether that has an effect or not depends on the configuration point, since it is not uncommon for engines to read the application configuration during initialization and set their own state from them. That process happens only on boot, not on reloads, and if that is how config.foo worked, resetting it would have no effect in the state of the engine.

    Allen Hsu & Xavier Noria

    👌 Support using environment variable to set pidfile.

    Ben Thorner


Previous changes from v6.1.0.rc2

  • 👍 Active Support

    ⏪ Ensure MemoryStore disables compression by default. Reverts behavior of
    🚅 MemoryStore to its prior rails 5.1 behavior.

    Max Gurewitz

    Active Model

    • No changes.

    Active Record

    Fix odd behavior of inverse_of with multiple belongs_to to same class.

    🛠 Fixes #35204.

    Tomoyuki Kai

    🏗 Build predicate conditions with objects that delegate #id and primary key:

    class AdminAuthordelegate\_missing\_to :@authordef initialize(author)@author = authorendendPost.where(author: AdminAuthor.new(author))
    

    Sean Doyle

    Action View

    🔄 Change form_with to generate non-remote forms by default.

    0️⃣ form_with would generate a remote form by default. This would confuse
    👉 users because they were forced to handle remote requests.

    0️⃣ All new 6.1 applications will generate non-remote forms by default.
    ⬆️ When upgrading a 6.0 application you can enable remote forms by default by
    setting config.action_view.form_with_generates_remote_forms to true.

    Petrik de Heus

    Action Pack

    👌 Support for the HTTP header Feature-Policy has been revised to reflect
    its rename to Permissions-Policy.

    Rails.application.config.permissions\_policy do |p| p.camera:nonep.gyroscope:nonep.microphone :nonep.usb:nonep.fullscreen :selfp.payment:self, "https://secure-example.com"end
    

    Julien Grillot

    👷 Active Job

    • No changes.

    Action Mailer

    • No changes.

    Action Cable

    • No changes.

    Active Storage

    Implement strict_loading on ActiveStorage associations.

    David Angulo

    Action Mailbox

    • No changes.

    Action Text

    • No changes.

    Railties

    • No changes.