## Rails 6.0.0.rc2 (July 22, 2019) ##
* `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*
## Rails 6.0.0.rc1 (April 24, 2019) ##
* Introduce `ActiveSupport::ActionableError`.
Actionable errors let's you dispatch actions from Rails' error pages. This
can help you save time if you have a clear action for the resolution of
common development errors.
The de-facto example are pending migrations. Every time pending migrations
are found, a middleware raises an error. With actionable errors, you can
run the migrations right from the error page. Other examples include Rails
plugins that need to run a rake task to setup themselves. They can now
raise actionable errors to run the setup straight from the error pages.
Here is how to define an actionable error:
```ruby
class PendingMigrationError < MigrationError #:nodoc:
include ActiveSupport::ActionableError
action "Run pending migrations" do
ActiveRecord::Tasks::DatabaseTasks.migrate
end
end
```
To make an error actionable, include the `ActiveSupport::ActionableError`
module and invoke the `action` class macro to define the action. An action
needs a name and a procedure to execute. The name is shown as the name of a
button on the error pages. Once clicked, it will invoke the given
procedure.
*Vipul A M*, *Yao Jie*, *Genadi Samokovarov*
* Preserve `html_safe?` status on `ActiveSupport::SafeBuffer#*`.
Before:
("
".html_safe * 2).html_safe? #=> nil
After:
("
".html_safe * 2).html_safe? #=> true
*Ryo Nakamura*
* Calling test methods with `with_info_handler` method to allow minitest-hooks
plugin to work.
*Mauri Mustonen*
* The Zeitwerk compatibility interface for `ActiveSupport::Dependencies` no
longer implements `autoloaded_constants` or `autoloaded?` (undocumented,
anyway). Experience shows introspection does not have many use cases, and
troubleshooting is done by logging. With this design trade-off we are able
to use even less memory in all environments.
*Xavier Noria*
* Depends on Zeitwerk 2, which stores less metadata if reloading is disabled
and hence uses less memory when `config.cache_classes` is `true`, a standard
setup in production.
*Xavier Noria*
* In `:zeitwerk` mode, eager load directories in engines and applications only
if present in their respective `config.eager_load_paths`.
A common use case for this is adding `lib` to `config.autoload_paths`, but
not to `config.eager_load_paths`. In that configuration, for example, files
in the `lib` directory should not be eager loaded.
*Xavier Noria*
* Fix bug in Range comparisons when comparing to an excluded-end Range
Before:
(1..10).cover?(1...11) # => false
After:
(1..10).cover?(1...11) # => true
With the same change for `Range#include?` and `Range#===`.
*Owen Stephens*
* Use weak references in descendants tracker to allow anonymous subclasses to
be garbage collected.
*Edgars Beigarts*
* Update `ActiveSupport::Notifications::Instrumenter#instrument` to make
passing a block optional. This will let users use
`ActiveSupport::Notifications` messaging features outside of
instrumentation.
*Ali Ibrahim*
* Fix `Time#advance` to work with dates before 1001-03-07
Before:
Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-05 00:00:00 UTC
After
Time.utc(1001, 3, 6).advance(years: -1) # => 1000-03-06 00:00:00 UTC
Note that this doesn't affect `DateTime#advance` as that doesn't use a proleptic calendar.
*Andrew White*
* In Zeitwerk mode, engines are now managed by the `main` autoloader. Engines may reference application constants, if the application is reloaded and we do not reload engines, they won't use the reloaded application code.
*Xavier Noria*
* Add support for supplying `locale` to `transliterate` and `parameterize`.
I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { "ü" => "ue" } } })
ActiveSupport::Inflector.transliterate("ü", locale: :de) # => "ue"
"Fünf autos".parameterize(locale: :de) # => "fuenf-autos"
ActiveSupport::Inflector.parameterize("Fünf autos", locale: :de) # => "fuenf-autos"
*Kaan Ozkan*, *Sharang Dashputre*
* Allow `Array#excluding` and `Enumerable#excluding` to deal with a passed array gracefully.
[ 1, 2, 3, 4, 5 ].excluding([4, 5]) # => [ 1, 2, 3 ]
*DHH*
* Renamed `Array#without` and `Enumerable#without` to `Array#excluding` and `Enumerable#excluding`, to create parity with
`Array#including` and `Enumerable#including`. Retained the old names as aliases.
*DHH*
* Added `Array#including` and `Enumerable#including` to conveniently enlarge a collection with more members using a method rather than an operator:
[ 1, 2, 3 ].including(4, 5) # => [ 1, 2, 3, 4, 5 ]
post.authors.including(Current.person) # => All the authors plus the current person!
*DHH*
## Rails 6.0.0.beta3 (March 11, 2019) ##
* No changes.
## Rails 6.0.0.beta2 (February 25, 2019) ##
* New autoloading based on [Zeitwerk](https://github.com/fxn/zeitwerk).
*Xavier Noria*
* Revise `ActiveSupport::Notifications.unsubscribe` to correctly handle Regex or other multiple-pattern subscribers.
*Zach Kemp*
* Add `before_reset` callback to `CurrentAttributes` and define `after_reset` as an alias of `resets` for symmetry.
*Rosa Gutierrez*
* Remove the `` Kernel#` `` override that suppresses ENOENT and accidentally returns nil on Unix systems.
*Akinori Musha*
* Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
`assoc` can now be called with either a string or a symbol.
*Stefan Schüßler*
* Add `Hash#deep_transform_values`, and `Hash#deep_transform_values!`.
*Guillermo Iguaran*
## Rails 6.0.0.beta1 (January 18, 2019) ##
* Remove deprecated `Module#reachable?` method.
*Rafael Mendonça França*
* Remove deprecated `#acronym_regex` method from `Inflections`.
*Rafael Mendonça França*
* Fix `String#safe_constantize` throwing a `LoadError` 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` for `ActiveSupport::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)` and `ActiveSuppport::Multibyte::Unicode#unpack_graphemes(string)`
in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
*Francesco Rodríguez*
* Deprecate `ActiveSupport::Multibyte::Chars.consumes?` in favor of `String#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` and `ActiveSuppport::Multibyte::Chars#normalize`
in favor of `String#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`, and `Module#parent_name` to
`module_parent`, `module_parents`, and `module_parent_name`.
*Gannon McGibbon*
* Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence`
*Edouard Chin*
* Deprecate using negative limits in `String#first` and `String#last`.
*Gannon McGibbon*, *Eric Turner*
* Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
with symbol arguments
*Abraham Chan*
* Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_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 of `travel_back` in `ActiveSupport::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 = "