Releases: rails/rails
5.2.5
Active Support
- No changes.
Active Model
- No changes.
Active Record
- No changes.
Action View
- No changes.
Action Pack
- No changes.
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
-
Marcel is upgraded to version 1.0.0 to avoid a dependency on GPL-licensed mime types data.
George Claghorn
Railties
- No changes.
6.1.3
Active Support
- No changes.
Active Model
- No changes.
Active Record
-
Fix the MySQL adapter to always set the right collation and charset
to the connection session.Rafael Mendonça França
-
Fix MySQL adapter handling of time objects when prepared statements
are enabled.Rafael Mendonça França
-
Fix scoping in enum fields using conditions that would generate
anIN
clause.Ryuta Kamizono
-
Skip optimised #exist? query when #include? is called on a relation
with a having clauseRelations that have aliased select values AND a having clause that
references an aliased select value would generate an error when
#include? was called, due to an optimisation that would generate
call #exists? on the relation instead, which effectively alters
the select values of the query (and thus removes the aliased select
values), but leaves the having clause intact. Because the having
clause is then referencing an aliased column that is no longer
present in the simplified query, an ActiveRecord::InvalidStatement
error was raised.An sample query affected by this problem:
Author.select('COUNT(*) as total_posts', 'authors.*') .joins(:posts) .group(:id) .having('total_posts > 2') .include?(Author.first)
This change adds an addition check to the condition that skips the
simplified #exists? query, which simply checks for the presence of
a having clause.Fixes #41417
Michael Smart
-
Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted
without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
up in perpetual crash state for being inconsistent with Postgres.wbharding, Martin Tepper
Action View
- No changes.
Action Pack
-
Re-define routes when not set correctly via inheritance.
John Hawthorn
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Action Mailbox
- No changes.
Action Text
- No changes.
Railties
- No changes.
6.1.2.1
Active Support
- No changes.
Active Model
- No changes.
Active Record
-
Fix possible DoS vector in PostgreSQL money type
Carefully crafted input can cause a DoS via the regular expressions used
for validating the money format in the PostgreSQL adapter. This patch
fixes the regexp.Thanks to @dee-see from Hackerone for this patch!
Aaron Patterson
Action View
- No changes.
Action Pack
-
Prevent open redirect when allowed host starts with a dot
Thanks to @TkTech (https://hackerone.com/tktech) for reporting this
issue and the patch!Aaron Patterson
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Action Mailbox
- No changes.
Action Text
- No changes.
Railties
- No changes.
6.0.3.5
Active Support
- No changes.
Active Model
- No changes.
Active Record
-
Fix possible DoS vector in PostgreSQL money type
Carefully crafted input can cause a DoS via the regular expressions used
for validating the money format in the PostgreSQL adapter. This patch
fixes the regexp.Thanks to @dee-see from Hackerone for this patch!
Aaron Patterson
Action View
- No changes.
Action Pack
-
Prevent open redirect when allowed host starts with a dot
Thanks to @TkTech (https://hackerone.com/tktech) for reporting this
issue and the patch!Aaron Patterson
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Action Mailbox
- No changes.
Action Text
- No changes.
Railties
- No changes.
5.2.4.5
Active Support
- No changes.
Active Model
- No changes.
Active Record
-
Fix possible DoS vector in PostgreSQL money type
Carefully crafted input can cause a DoS via the regular expressions used
for validating the money format in the PostgreSQL adapter. This patch
fixes the regexp.Thanks to @dee-see from Hackerone for this patch!
Aaron Patterson
Action View
- No changes.
Action Pack
- No changes.
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Railties
- No changes.
6.1.2
Active Support
-
ActiveSupport::Cache::MemCacheStore
now accepts an explicitnil
for itsaddresses
argument.config.cache_store = :mem_cache_store, nil # is now equivalent to config.cache_store = :mem_cache_store # and is also equivalent to config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211" # which is the fallback behavior of Dalli
This helps those migrating from
:dalli_store
, where an explicitnil
was permitted.Michael Overmeyer
Active Model
- No changes.
Active Record
-
Fix timestamp type for sqlite3.
Eileen M. Uchitelle
-
Make destroy async transactional.
An active record rollback could occur while enqueuing a job. In this
case the job would enqueue even though the database deletion
rolledback putting things in a funky state.Now the jobs are only enqueued until after the db transaction has been committed.
Cory Gwin
-
Fix malformed packet error in MySQL statement for connection configuration.
robinroestenburg
-
Connection specification now passes the "url" key as a configuration for the
adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
are assumed to be adapter specification urls.Fixes #41137.
Jonathan Bracy
-
Fix granular connection swapping when there are multiple abstract classes.
Eileen M. Uchitelle
-
Fix
find_by
with custom primary key for belongs_to association.Ryuta Kamizono
-
Add support for
rails console --sandbox
for multiple database applications.alpaca-tc
-
Fix
where
on polymorphic association with empty array.Ryuta Kamizono
-
Fix preventing writes for
ApplicationRecord
.Eileen M. Uchitelle
Action View
- No changes.
Action Pack
-
Fix error in
ActionController::LogSubscriber
that would happen when throwing inside a controller action.Janko Marohnić
-
Fix
fixture_file_upload
deprecation whenfile_fixture_path
is a relative path.Eugene Kenny
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Action Mailbox
- No changes.
Action Text
- No changes.
Railties
- No changes.
6.1.1
Active Support
-
Change
IPAddr#to_json
to match the behavior of the json gem returning the string representation
instead of the instance variables of the object.Before:
IPAddr.new("127.0.0.1").to_json # => "{\"addr\":2130706433,\"family\":2,\"mask_addr\":4294967295}"
After:
IPAddr.new("127.0.0.1").to_json # => "\"127.0.0.1\""
Active Model
- No changes.
Active Record
-
Fix fixtures loading when strict loading is enabled for the association.
Alex Ghiculescu
-
Fix
where
with custom primary key for belongs_to association.Ryuta Kamizono
-
Fix
where
with aliased associations.Ryuta Kamizono
-
Fix
composed_of
with symbol mapping.Ryuta Kamizono
-
Don't skip money's type cast for pluck and calculations.
Ryuta Kamizono
-
Fix
where
on polymorphic association with non Active Record object.Ryuta Kamizono
-
Make sure
db:prepare
works even the schema file doesn't exist.Rafael Mendonça França
-
Fix complicated
has_many :through
with nested where condition.Ryuta Kamizono
-
Handle STI models for
has_many dependent: :destroy_async
.Muhammad Usman
-
Restore possibility of passing
false
to :polymorphic option ofbelongs_to
.Previously, passing
false
would trigger the option validation logic
to throw an error saying :polymorphic would not be a valid option.glaszig
-
Allow adding nonnamed expression indexes to be revertible.
Fixes #40732.
Previously, the following code would raise an error, when executed while rolling back,
and the index name should be specified explicitly. Now, the index name is inferred
automatically.add_index(:items, "to_tsvector('english', description)")
fatkodima
Action View
-
Fix lazy translation in partial with block.
Marek Kasztelnik
-
Avoid extra
SELECT COUNT
queries when rendering Active Record collections.aar0nr
-
Link preloading keep integrity hashes in the header.
Étienne Barrié
-
Add
config.action_view.preload_links_header
to allow disabling of
theLink
header being added by default when usingstylesheet_link_tag
andjavascript_include_tag
.Andrew White
-
The
translate
helper now resolvesdefault
values when anil
key is
specified, instead of always returningnil
.Jonathan Hefner
Action Pack
-
Fix nil translation key lookup in controllers/
Jan Klimo
-
Quietly handle unknown HTTP methods in Action Dispatch SSL middleware.
Alex Robbin
-
Change the request method to a
GET
when passing failed requests down toconfig.exceptions_app
.Alex Robbin
Active Job
-
Make
retry_job
return the job that was created.Rafael Mendonça França
-
Include
ActiveSupport::Testing::Assertions
inActiveJob::TestHelpers
.Mikkel Malmberg
Action Mailer
-
Sets default mailer queue to
"default"
in the mail assertions.Paul Keen
Action Cable
- No changes.
Active Storage
-
Fix S3 multipart uploads when threshold is larger than file.
Matt Muller
Action Mailbox
- No changes.
Action Text
- No changes.
Railties
-
Allow spaces in path to Yarn binstub and only run on precompile if needed.
Markus Doits
-
Populate ARGV for app template.
Fixes #40945.
Jonathan Hefner
6.1.0
Active Support
-
Ensure
MemoryStore
disables compression by default. Reverts behavior of
MemoryStore
to its prior rails5.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
andActiveSupport::Multibyte::Unicode.swapcase
.Rafael Mendonça França
-
Remove deprecated
ActiveSupport::Multibyte::Chars#consumes?
andActiveSupport::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
andModule#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
whenconfig.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 checksENV["MEMCACHE_SERVERS"]
before falling back to"localhost:11211"
if configured without any addresses.config.cache_store = :mem_cache_store # is now equivalent to config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211" # instead of config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
Sam Bostock
-
ActiveSupport::Subscriber#attach_to
now accepts aninherit_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::Subscriber attach_to :action_controller def start_processing(event) info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}" end def redirect_to(event) info { "Redirected to #{event.payload[:location]}" } end end # We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber # can provide its own instrumentation for certain events in the namespace ActionControllerSubscriber.detach_from(:action_controller) class CustomActionControllerSubscriber < ActionControllerSubscriber attach_to :action_controller, inherit_all: true def 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" notifications end
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 ofconfig.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 methodsin_seconds
,in_minutes
,in_hours
,in_days
,in_weeks
,in_months
, andin_years
return the respective duration covered.Jason York
-
Fixed issue in
ActiveSupport::Cache::RedisCacheStore
not passing options
toread_multi
causingfetch_multi
to not work properlyRajesh Sharma
-
Fixed issue in
ActiveSupport::Cache::MemCacheStore
which caused duplicate compression,
and caused the providedcompression_threshold
to not be respected.Max Gurewitz
-
Prevent
RedisCacheStore
andMemCacheStore
from performing compression
when reading entries written withraw: true
.Max Gurewitz
-
URI.parser
is deprecated and will be removed in Rails 6.2. Use
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?
andSymbol#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 returnsfalse
, 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.rbSee 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 complementActiveRecord::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 < ApplicationRecord before_save { throw(:abort) } before_create { throw(:abort) } def halted_callback_hook(filter, callback_name) Rails.logger.info("Book couldn't be #{callback_name}d") end Book.create # => "Book couldn't be created" book.save # => "Book couldn't be save...
6.1.0.rc2
Active Support
-
Ensure
MemoryStore
disables compression by default. Reverts behavior of
MemoryStore
to its prior rails5.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 AdminAuthor delegate_missing_to :@author def initialize(author) @author = author end end Post.where(author: AdminAuthor.new(author))
Sean Doyle
Action View
-
Change form_with to generate non-remote forms by default.
form_with
would generate a remote form by default. This would confuse
users because they were forced to handle remote requests.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
settingconfig.action_view.form_with_generates_remote_forms
totrue
.Petrik de Heus
Action Pack
-
Support for the HTTP header
Feature-Policy
has been revised to reflect
its rename toPermissions-Policy
.Rails.application.config.permissions_policy do |p| p.camera :none p.gyroscope :none p.microphone :none p.usb :none p.fullscreen :self p.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.
6.1.0.rc1
Active Support
-
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
andActiveSupport::Multibyte::Unicode.swapcase
.Rafael Mendonça França
-
Remove deprecated
ActiveSupport::Multibyte::Chars#consumes?
andActiveSupport::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
andModule#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
whenconfig.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 checksENV["MEMCACHE_SERVERS"]
before falling back to"localhost:11211"
if configured without any addresses.config.cache_store = :mem_cache_store # is now equivalent to config.cache_store = :mem_cache_store, ENV["MEMCACHE_SERVERS"] || "localhost:11211" # instead of config.cache_store = :mem_cache_store, "localhost:11211" # ignores ENV["MEMCACHE_SERVERS"]
Sam Bostock
-
ActiveSupport::Subscriber#attach_to
now accepts aninherit_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::Subscriber attach_to :action_controller def start_processing(event) info "Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}" end def redirect_to(event) info { "Redirected to #{event.payload[:location]}" } end end # We detach ActionControllerSubscriber from the :action_controller namespace so that our CustomActionControllerSubscriber # can provide its own instrumentation for certain events in the namespace ActionControllerSubscriber.detach_from(:action_controller) class CustomActionControllerSubscriber < ActionControllerSubscriber attach_to :action_controller, inherit_all: true def 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" notifications end
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 ofconfig.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 methodsin_seconds
,in_minutes
,in_hours
,in_days
,in_weeks
,in_months
, andin_years
return the respective duration covered.Jason York
-
Fixed issue in
ActiveSupport::Cache::RedisCacheStore
not passing options
toread_multi
causingfetch_multi
to not work properlyRajesh Sharma
-
Fixed issue in
ActiveSupport::Cache::MemCacheStore
which caused duplicate compression,
and caused the providedcompression_threshold
to not be respected.Max Gurewitz
-
Prevent
RedisCacheStore
andMemCacheStore
from performing compression
when reading entries written withraw: true
.Max Gurewitz
-
URI.parser
is deprecated and will be removed in Rails 6.2. Use
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?
andSymbol#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 returnsfalse
, 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.rbSee 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 complementActiveRecord::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 < ApplicationRecord before_save { throw(:abort) } before_create { throw(:abort) } def halted_callback_hook(filter, callback_name) Rails.logger.info("Book couldn't be #{callback_name}d") end Book.create # => "Book couldn't be created" book.save # => "Book couldn't be saved" end
Edouard Chin
-
Support
prepend
withActiveSupport::Concern
.Allows a module with `extend ActiveSupport::Concern...