Releases: rails/rails
5.2.3
Active Support
-
Add
ActiveSupport::HashWithIndifferentAccess#assoc
.assoc
can now be called with either a string or a symbol.Stefan Schüßler
-
Fix
String#safe_constantize
throwing aLoadError
for incorrectly cased constant references.Keenan Brock
-
Allow Range#=== and Range#cover? on Range
Range#cover?
can now accept a range argument likeRange#include?
and
Range#===
.Range#===
works correctly on Ruby 2.6.Range#include?
is moved
into a new file, with these two methods.utilum
-
If the same block is
included
multiple times for a Concern, an exception is no longer raised.Mark J. Titorenko, Vlad Bokov
Active Model
-
Fix date value when casting a multiparameter date hash to not convert
from Gregorian date to Julian date.Before:
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"}) => #<Day id: nil, day: "0001-01-03", created_at: nil, updated_at: nil>
After:
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"}) => #<Day id: nil, day: "0001-01-01", created_at: nil, updated_at: nil>
Fixes #28521.
Sayan Chakraborty
-
Fix numericality equality validation of
BigDecimal
andFloat
by casting toBigDecimal
on both ends of the validation.Gannon McGibbon
Active Record
-
Fix different
count
calculation when usingsize
with manualselect
with DISTINCT.Fixes #35214.
Juani Villarejo
-
Fix prepared statements caching to be enabled even when query caching is enabled.
Ryuta Kamizono
-
Don't allow
where
with invalid value matches to nil values.Fixes #33624.
Ryuta Kamizono
-
Restore an ability that class level
update
without giving ids.Fixes #34743.
Ryuta Kamizono
-
Fix join table column quoting with SQLite.
Gannon McGibbon
-
Ensure that
delete_all
on collection proxy returns affected count.Ryuta Kamizono
-
Reset scope after delete on collection association to clear stale offsets of removed records.
Gannon McGibbon
Action View
-
Prevent non-primary mouse keys from triggering Rails UJS click handlers.
Firefox fires click events even if the click was triggered by non-primary mouse keys such as right- or scroll-wheel-clicks.
For example, right-clicking a link such as the one described below (with an underlying ajax request registered on click) should not cause that request to occur.<%= link_to 'Remote', remote_path, class: 'remote', remote: true, data: { type: :json } %>
Fixes #34541
Wolfgang Hobmaier
Action Pack
-
Allow using combine the Cache Control
public
andno-cache
headers.Before this change, even if
public
was specified for Cache Control header,
it was excluded whenno-cache
was included. This fixed to keeppublic
header as is.Fixes #34780.
Yuji Yaginuma
-
Allow
nil
params forActionController::TestCase
.Ryo Nakamura
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Railties
-
Seed database with inline ActiveJob job adapter.
Gannon McGibbon
-
Fix boolean interaction in scaffold system tests.
Gannon McGibbon
5.1.7
Active Support
- No changes.
Active Model
- No changes.
Active Record
-
Fix
touch
option to behave consistently withPersistence#touch
method.Ryuta Kamizono
-
Back port Rails 5.2
reverse_order
Arel SQL literal fix.Matt Jones, Brooke Kuhlmann
-
becomes
should clear the mutation tracker which is created inafter_initialize
.Fixes #32867.
Ryuta Kamizono
Action View
-
Fix issue with
button_to
'sto_form_params
button_to
was throwing exception when invoked withparams
hash that
contains symbol and string keys. The reason for the exception was that
to_form_params
was comparing the given symbol and string keys.The issue is fixed by turning all keys to strings inside
to_form_params
before comparing them.Georgi Georgiev
Action Pack
- No changes.
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Railties
- No changes.
5.2.3.rc1
Active Support
-
Add
ActiveSupport::HashWithIndifferentAccess#assoc
.assoc
can now be called with either a string or a symbol.Stefan Schüßler
-
Fix
String#safe_constantize
throwing aLoadError
for incorrectly cased constant references.Keenan Brock
-
Allow Range#=== and Range#cover? on Range
Range#cover?
can now accept a range argument likeRange#include?
and
Range#===
.Range#===
works correctly on Ruby 2.6.Range#include?
is moved
into a new file, with these two methods.utilum
-
If the same block is
included
multiple times for a Concern, an exception is no longer raised.Mark J. Titorenko, Vlad Bokov
Active Model
-
Fix date value when casting a multiparameter date hash to not convert
from Gregorian date to Julian date.Before:
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"}) => #<Day id: nil, day: "0001-01-03", created_at: nil, updated_at: nil>
After:
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"}) => #<Day id: nil, day: "0001-01-01", created_at: nil, updated_at: nil>
Fixes #28521.
Sayan Chakraborty
-
Fix numericality equality validation of
BigDecimal
andFloat
by casting toBigDecimal
on both ends of the validation.Gannon McGibbon
Active Record
-
Fix different
count
calculation when usingsize
with manualselect
with DISTINCT.Fixes #35214.
Juani Villarejo
-
Fix prepared statements caching to be enabled even when query caching is enabled.
Ryuta Kamizono
-
Don't allow
where
with invalid value matches to nil values.Fixes #33624.
Ryuta Kamizono
-
Restore an ability that class level
update
without giving ids.Fixes #34743.
Ryuta Kamizono
-
Fix join table column quoting with SQLite.
Gannon McGibbon
-
Ensure that
delete_all
on collection proxy returns affected count.Ryuta Kamizono
-
Reset scope after delete on collection association to clear stale offsets of removed records.
Gannon McGibbon
Action View
-
Prevent non-primary mouse keys from triggering Rails UJS click handlers.
Firefox fires click events even if the click was triggered by non-primary mouse keys such as right- or scroll-wheel-clicks.
For example, right-clicking a link such as the one described below (with an underlying ajax request registered on click) should not cause that request to occur.<%= link_to 'Remote', remote_path, class: 'remote', remote: true, data: { type: :json } %>
Fixes #34541
Wolfgang Hobmaier
Action Pack
-
Allow using combine the Cache Control
public
andno-cache
headers.Before this change, even if
public
was specified for Cache Control header,
it was excluded whenno-cache
was included. This fixed to keeppublic
header as is.Fixes #34780.
Yuji Yaginuma
-
Allow
nil
params forActionController::TestCase
.Ryo Nakamura
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
- No changes.
Railties
-
Seed database with inline ActiveJob job adapter.
Gannon McGibbon
-
Fix boolean interaction in scaffold system tests.
Gannon McGibbon
5.1.7.rc1
Active Support
- No changes.
Active Model
- No changes.
Active Record
-
Fix
touch
option to behave consistently withPersistence#touch
method.Ryuta Kamizono
-
Back port Rails 5.2
reverse_order
Arel SQL literal fix.Matt Jones, Brooke Kuhlmann
-
becomes
should clear the mutation tracker which is created inafter_initialize
.Fixes #32867.
Ryuta Kamizono
Action View
-
Fix issue with
button_to
'sto_form_params
button_to
was throwing exception when invoked withparams
hash that
contains symbol and string keys. The reason for the exception was that
to_form_params
was comparing the given symbol and string keys.The issue is fixed by turning all keys to strings inside
to_form_params
before comparing them.Georgi Georgiev
Action Pack
- No changes.
Active Job
- No changes.
Action Mailer
- No changes.
Action Cable
- No changes.
Railties
- No changes.
6.0.0.beta1
Active Support
-
Remove deprecated
Module#reachable?
method.Rafael Mendonça França
-
Remove deprecated
#acronym_regex
method fromInflections
.Rafael Mendonça França
-
Fix
String#safe_constantize
throwing aLoadError
for incorrectly cased constant references.Keenan Brock
-
Preserve key order passed to
ActiveSupport::CacheStore#fetch_multi
.fetch_multi(*names)
now returns its results in the same order as the*names
requested, rather than returning cache hits followed by cache misses.Gannon McGibbon
-
If the same block is
included
multiple times for a Concern, an exception is no longer raised.Mark J. Titorenko, Vlad Bokov
-
Fix bug where
#to_options
forActiveSupport::HashWithIndifferentAccess
would not act as alias for#symbolize_keys
.Nick Weiland
-
Improve the logic that detects non-autoloaded constants.
Jan Habermann, Xavier Noria
-
Deprecate
ActiveSupport::Multibyte::Unicode#pack_graphemes(array)
andActiveSuppport::Multibyte::Unicode#unpack_graphemes(string)
in favor ofarray.flatten.pack("U*")
andstring.scan(/\X/).map(&:codepoints)
, respectively.Francesco Rodríguez
-
Deprecate
ActiveSupport::Multibyte::Chars.consumes?
in favor ofString#is_utf8?
.Francesco Rodríguez
-
Fix duration being rounded to a full second.
time = DateTime.parse("2018-1-1") time += 0.51.seconds
Will now correctly add 0.51 second and not 1 full second.
Edouard Chin
-
Deprecate
ActiveSupport::Multibyte::Unicode#normalize
andActiveSuppport::Multibyte::Chars#normalize
in favor ofString#unicode_normalize
Francesco Rodríguez
-
Deprecate
ActiveSupport::Multibyte::Unicode#downcase/upcase/swapcase
in favor of
String#downcase/upcase/swapcase
.Francesco Rodríguez
-
Add
ActiveSupport::ParameterFilter
.Yoshiyuki Kinjo
-
Rename
Module#parent
,Module#parents
, andModule#parent_name
to
module_parent
,module_parents
, andmodule_parent_name
.Gannon McGibbon
-
Deprecate the use of
LoggerSilence
in favor ofActiveSupport::LoggerSilence
Edouard Chin
-
Deprecate using negative limits in
String#first
andString#last
.Gannon McGibbon, Eric Turner
-
Fix bug where
#without
forActiveSupport::HashWithIndifferentAccess
would fail
with symbol argumentsAbraham Chan
-
Treat
#delete_prefix
,#delete_suffix
and#unicode_normalize
results as non-html_safe
.
Ensure safety of arguments for#insert
,#[]=
and#replace
calls onhtml_safe
Strings.Janosch Müller
-
Changed
ActiveSupport::TaggedLogging.new
to return a new logger instance instead
of mutating the one received as parameter.Thierry Joyal
-
Define
unfreeze_time
as an alias oftravel_back
inActiveSupport::Testing::TimeHelpers
.The alias is provided for symmetry with
freeze_time
.Ryan Davidson
-
Add support for tracing constant autoloads. Just throw
ActiveSupport::Dependencies.logger = Rails.logger ActiveSupport::Dependencies.verbose = true
in an initializer.
Xavier Noria
-
Maintain
html_safe?
on html_safe strings when sliced.string = "<div>test</div>".html_safe string[-1..1].html_safe? # => true
Elom Gomez, Yumin Wong
-
Add
Array#extract!
.The method removes and returns the elements for which the block returns a true value.
If no block is given, an Enumerator is returned instead.numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] odd_numbers = numbers.extract! { |number| number.odd? } # => [1, 3, 5, 7, 9] numbers # => [0, 2, 4, 6, 8]
bogdanvlviv
-
Support not to cache
nil
forActiveSupport::Cache#fetch
.cache.fetch('bar', skip_nil: true) { nil } cache.exist?('bar') # => false
Martin Hong
-
Add "event object" support to the notification system.
Before this change, end users were forced to create hand made artisanal
event objects on their own, like this:ActiveSupport::Notifications.subscribe('wait') do |*args| @event = ActiveSupport::Notifications::Event.new(*args) end ActiveSupport::Notifications.instrument('wait') do sleep 1 end @event.duration # => 1000.138
After this change, if the block passed to
subscribe
only takes one
parameter, the framework will yield an event object to the block. Now
end users are no longer required to make their own:ActiveSupport::Notifications.subscribe('wait') do |event| @event = event end ActiveSupport::Notifications.instrument('wait') do sleep 1 end p @event.allocations # => 7 p @event.cpu_time # => 0.256 p @event.idle_time # => 1003.2399
Now you can enjoy event objects without making them yourself. Neat!
Aaron "t.lo" Patterson
-
Add cpu_time, idle_time, and allocations to Event.
Eileen M. Uchitelle, Aaron Patterson
-
RedisCacheStore: support key expiry in increment/decrement.
Pass
:expires_in
to#increment
and#decrement
to set a Redis EXPIRE on the key.If the key is already set to expire, RedisCacheStore won't extend its expiry.
Rails.cache.increment("some_key", 1, expires_in: 2.minutes)
Jason Lee
-
Allow
Range#===
andRange#cover?
on Range.Range#cover?
can now accept a range argument likeRange#include?
and
Range#===
.Range#===
works correctly on Ruby 2.6.Range#include?
is moved
into a new file, with these two methods.Requiring active_support/core_ext/range/include_range is now deprecated.
Userequire "active_support/core_ext/range/compare_range"
instead.utilum
-
Add
index_with
to Enumerable.Allows creating a hash from an enumerable with the value from a passed block
or a default argument.%i( title body ).index_with { |attr| post.public_send(attr) } # => { title: "hey", body: "what's up?" } %i( title body ).index_with(nil) # => { title: nil, body: nil }
Closely linked with
index_by
, which creates a hash where the keys are extracted from a block.Kasper Timm Hansen
-
Fix bug where
ActiveSupport::Timezone.all
would fail when tzinfo data for
any timezone defined inActiveSupport::TimeZone::MAPPING
is missing.Dominik Sander
-
Redis cache store:
delete_matched
no longer blocks the Redis server.
(Switches from evaled Lua to a batched SCAN + DEL loop.)Gleb Mazovetskiy
-
Fix bug where
ActiveSupport::Cache
will massively inflate the storage
size when compression is enabled (which is true by default). This patch
does not attempt to repair existing data: please manually flush the cache
to clear out the problematic entries.Godfrey Chan
-
Fix bug where
URI.unescape
would fail with mixed Unicode/escaped character input:URI.unescape("\xe3\x83\x90") # => "バ" URI.unescape("%E3%83%90") # => "バ" URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
Ashe Connor, Aaron Patterson
-
Add
before?
andafter?
methods toDate
,DateTime
,
Time
, andTimeWithZone
.Nick Holden
-
ActiveSupport::Inflector#ordinal
andActiveSupport::Inflector#ordinalize
now support
translations through I18n.# locale/fr.rb { fr: { number: { nth: { ordinals: lambda do |_key, number:, **_options| if number.to_i.abs == 1 'er' else 'e' end end, ordinalized: lambda do |_key, number:, **_options| "#{number}#{ActiveSupport::Inflector.ordinal(number)}" end } } } }
Christian Blais
-
Add
:private
option to ActiveSupport'sModule#delegate
in order to delegate methods as private:class User < ActiveRecord::Base has_one :profile delegate :date_of_birth, to: :profile, private: true def age Date.today.year - date_of_birth.year end end # User.new.age # => 29 # User.new.date_of_birth # => NoMethodError: private method `date_of_birth' called for #<User:0x00000008221340>
Tomas Valent
-
String#truncate_bytes
to truncate a string to a maximum bytesize without
breaking multibyte characters or grapheme clusters like 👩👩👦👦.Jeremy Daer
-
String#strip_heredoc
preserves frozenness."foo".freeze.strip_heredoc.frozen? # => true
Fixes that frozen string literals would inadvertently become unfrozen:
# frozen_string_literal: true foo = <<-MSG.strip_heredoc la la la MSG foo.frozen? # => false !??
Jeremy Daer
-
Rails 6 requires Ruby 2.5.0 or newer.
Jeremy Daer, Kasper Timm Hansen
-
Adds parallel testing to Rails.
Parallelize your test suite with forked processes or threads.
Eileen M. Uchitelle, Aaron Patterson
Active Model
-
Add
ActiveModel::Errors#of_kind?
.bogdanvlviv, Rafael Mendonça França
-
Fix numericality equality validation of
BigDecimal
andFloat
by casting toBigDecimal
on both ends of the validation.Gannon McGibbon
-
Add
#slice!
method toActiveModel::Errors
....
5.2.2
Active Support
-
Fix bug where
#to_options
forActiveSupport::HashWithIndifferentAccess
would not act as alias for#symbolize_keys
.Nick Weiland
-
Improve the logic that detects non-autoloaded constants.
Jan Habermann, Xavier Noria
-
Fix bug where
URI.unescape
would fail with mixed Unicode/escaped character input:URI.unescape("\xe3\x83\x90") # => "バ" URI.unescape("%E3%83%90") # => "バ" URI.unescape("\xe3\x83\x90%E3%83%90") # => Encoding::CompatibilityError
Ashe Connor, Aaron Patterson
Active Model
-
Fix numericality validator to still use value before type cast except Active Record.
Ryuta Kamizono
Active Record
-
Do not ignore the scoping with query methods in the scope block.
Ryuta Kamizono
-
Allow aliased attributes to be used in
#update_columns
and#update
.Gannon McGibbon
-
Allow spaces in postgres table names.
Fixes issue where "user post" is misinterpreted as ""user"."post"" when quoting table names with the postgres
adapter.Gannon McGibbon
-
Cached columns_hash fields should be excluded from ResultSet#column_types
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
was passing for SQLite and MySQL, but failed for PostgreSQL:class DeveloperName < ActiveRecord::Type::String def deserialize(value) "Developer: #{value}" end end class AttributedDeveloper < ActiveRecord::Base self.table_name = "developers" attribute :name, DeveloperName.new self.ignored_columns += ["name"] end developer = AttributedDeveloper.create developer.update_column :name, "name" loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first puts loaded_developer.name # should be "Developer: name" but it's just "name"
Dmitry Tsepelev
-
Values of enum are frozen, raising an error when attempting to modify them.
Emmanuel Byrd
-
update_columns
now correctly raisesActiveModel::MissingAttributeError
if the attribute does not exist.Sean Griffin
-
Do not use prepared statement in queries that have a large number of binds.
Ryuta Kamizono
-
Fix query cache to load before first request.
Eileen M. Uchitelle
-
Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
Fixes #33056.
Federico Martinez
-
Fix duplicated record creation when using nested attributes with
create_with
.Darwin Wu
-
Fix regression setting children record in parent
before_save
callback.Guo Xiang Tan
-
Prevent leaking of user's DB credentials on
rails db:create
failure.bogdanvlviv
-
Clear mutation tracker before continuing the around callbacks.
Yuya Tanaka
-
Prevent deadlocks when waiting for connection from pool.
Brent Wheeldon
-
Avoid extra scoping when using
Relation#update
that was causing this method to change the current scope.Ryuta Kamizono
-
Fix numericality validator not to be affected by custom getter.
Ryuta Kamizono
-
Fix bulk change table ignores comment option on PostgreSQL.
Yoshiyuki Kinjo
Action View
- No changes.
Action Pack
-
Reset Capybara sessions if failed system test screenshot raising an exception.
Reset Capybara sessions if
take_failed_screenshot
raise exception
in system testafter_teardown
.Maxim Perepelitsa
-
Use request object for context if there's no controller
There is no controller instance when using a redirect route or a
mounted rack application so pass the request object as the context
when resolving dynamic CSP sources in this scenario.Fixes #34200.
Andrew White
-
Apply mapping to symbols returned from dynamic CSP sources
Previously if a dynamic source returned a symbol such as :self it
would be converted to a string implicity, e.g:policy.default_src -> { :self }
would generate the header:
Content-Security-Policy: default-src self
and now it generates:
Content-Security-Policy: default-src 'self'
Andrew White
-
Fix
rails routes -c
for controller name consists of multiple word.Yoshiyuki Kinjo
-
Call the
#redirect_to
block in controller context.Steven Peckins
Active Job
-
Make sure
assert_enqueued_with()
&assert_performed_with()
work reliably with hash arguments.Sharang Dashputre
-
Restore
ActionController::Parameters
support toActiveJob::Arguments.serialize
.Bernie Chiu
-
Restore
HashWithIndifferentAccess
support toActiveJob::Arguments.deserialize
.Gannon McGibbon
-
Include deserialized arguments in job instances returned from
assert_enqueued_with
andassert_performed_with
Alan Wu
-
Increment execution count before deserialize arguments.
Currently, the execution count increments after deserializes arguments.
Therefore, if an error occurs with deserialize, it retries indefinitely.Yuji Yaginuma
Action Mailer
- No changes.
Action Cable
- No changes.
Active Storage
-
Support multiple submit buttons in Active Storage forms.
Chrıs Seelus
-
Fix
ArgumentError
when uploading to amazon s3Hiroki Sanpei
-
Add a foreign-key constraint to the
active_storage_attachments
table for blobs.George Claghorn
-
Discard
ActiveStorage::PurgeJobs
for missing blobs.George Claghorn
-
Fix uploading Tempfiles to Azure Storage.
George Claghorn
Railties
-
Disable content security policy for mailer previews.
Dylan Reile
-
Log the remote IP address of clients behind a proxy.
Atul Bhosale