Rails 4.0.1 (November 01, 2013)

  • Disable the ability to iterate over Range of AS::TimeWithZone due to significant performance issues.

    Bogdan Gusiev

  • Fix ActiveSupport::Cache::FileStore#cleanupto no longer rely on missing each_keymethod.

    Murray Steele

  • Ensure that autoloaded constants in all-caps nestings are marked as autoloaded.

    Simon Coffey

  • Adds a new deprecation behaviour that raises an exception. Throwing this line into config/environments/development.rb:

    ActiveSupport::Deprecation.behavior = :raise

    will cause the application to raise an ActiveSupport::DeprecationExceptionon deprecations.

    Use this for aggressive deprecation cleanups.

    Xavier Noria

  • Improve ActiveSupport::Cache::MemoryStorecache size calculation. The memory used by a key/entry pair is calculated via #cached_size:

    def cached_size(key, entry)
      key.to_s.bytesize + entry.size + PER_ENTRY_OVERHEAD

    The value of PER_ENTRY_OVERHEADis 240 bytes based on an empirical estimation for 64-bit MRI on 1.9.3 and 2.0.

    Fixes #11512.

    Simeon Simeonov

  • Only raise Module::DelegationErrorif it's the source of the exception.

    Fixes #10559.

  • Add DateTime#usecand DateTime#nsecso that ActiveSupport::TimeWithZonekeeps sub-second resolution when wrapping a DateTimevalue.

    Fixes #10855.

    Andrew White

  • Make Time.at_with_coercionretain the second fraction and return local time.

    Fixes #11350.

    Neer Friedman, Andrew White

  • Fix return value from BacktraceCleaner#noisewhen the cleaner is configured with multiple silencers.

    Fixes #11030.

    Mark J. Titorenko

  • Fix ActiveSupport::Dependencies::Loadable#load_dependency calling #blame_file!on Exceptions that do not have the Blamable mixin

    Andrew Kreiling

Rails 4.0.0 (June 25, 2013)

  • Override Time.atto support the passing of Time-like values when called with a single argument.

    Andrew White

  • Allow Date to be compared with Time (like it was possible to compare Time with Date).


  • Deprecate multiple parameters support of Object#in?.

    Brian Morearty + Carlos Antonio da Silva

  • An ActiveSupport::Subscriberclass has been extracted from ActiveSupport::LogSubscriber, allowing you to use the event attachment API for other kinds of subscribers.

    Daniel Schierbeck

  • Class#class_attributeaccepts an instance_predicateoption which defaults to true. If set to falsethe predicate method will not be defined.

    Agis Anastasopoulos

  • fast_xssupport has been removed. Use String#encode(xml: :attr) .

  • ActiveSupport::Notifications::Instrumenter#instrumentshould yield its payload.


  • ActiveSupport::TimeWithZoneraises NoMethodError in proper context. Fixes #9772.

    Yves Senn

  • Fix deletion of empty directories in ActiveSupport::Cache::FileStore.

    Charles Jones

  • Improve singularizing a singular for multiple cases. Fixes #2608 #1825 #2395.


    # Before
    'address'.singularize # => 'addres'
    # After
    'address'.singularize # => 'address'

    Mark McSpadden

  • Prevent DateTime#changefrom truncating the second fraction, when seconds do not need to be changed.

    Chris Baynes

  • Added ActiveSupport::TimeWithZone#to_rfor Time#atcompatibility.

    Before this change:

    Time.zone = 'Tokyo'
    time = Time.zone.now
    time == Time.at(time) # => false

    After the change:

    Time.zone = 'Tokyo'
    time = Time.zone.now
    time == Time.at(time) # => true


  • ActiveSupport::NumberHelper#number_to_humanreturns the number unaltered when the given units hash does not contain the needed key, e.g. when the number provided is less than the largest key provided. Fixes #9269.


    number_to_human(123, units: {}) # => 123
    number_to_human(123, units: { thousand: 'k' }) # => 123

    Michael Hoffman

  • Added beginning_of_minutesupport to core ext calculations for Timeand DateTime.

    Gagan Awhad

  • Add :nsecdate format.

    Jamie Gaskins

  • ActiveSupport::Gzip.compressallows two optional arguments for compression level and strategy.


  • Modify TimeWithZone#as_jsonto include 3 decimal places of sub-second accuracy by default, which is optional as per the ISO8601 spec, but extremely useful. Also the default behaviour of Date#toJSON()in recent versions of Chrome, Safari and Firefox.

    James Harton

  • Improve String#squishto handle Unicode whitespace. Antoine Lyset

  • Standardise on to_timereturning an instance of Timein the local system timezone across String, Time, Date, DateTimeand ActiveSupport::TimeWithZone.

    Andrew White

  • Extract ActiveSupport::Testing::Performanceinto github.com/rails/rails-perftest You can add the gem to your Gemfileto keep using performance tests.

    gem 'rails-perftest'

    Yves Senn

  • Hash.from_xmlraises when it encounters type="symbol"or type="yaml". Use Hash.from_trusted_xmlto parse this XML.


    Jeremy Kemper

  • Deprecate assert_presentand assert_blankin favor of assert object.blank?and assert object.present?

    Yves Senn

  • Change String#to_dateto use Date.parse. This gives more consistent error messages and allows the use of partial dates.

    "gibberish".to_date => Argument Error: invalid date
    "3rd Feb".to_date => Sun, 03 Feb 2013

    Kelly Stannard

  • Remove meaningless ActiveSupport::FrozenObjectError, which was just an alias of RuntimeError.

    Akira Matsuda

  • Introduce assert_notto replace warty assert !foo . Jeremy Kemper

  • Prevent Callbacks#set_callbackfrom setting the same callback twice.

    before_save :foo, :bar, :foo

    will at first call bar, then foo. foowill no more be called twice.

    Dmitriy Kiriyenko

  • Add ActiveSupport::Logger#silencethat works the same as the old Logger#silenceextension.


  • Remove surrogate unicode character encoding from ActiveSupport::JSON.encodeThe encoding scheme was broken for unicode characters outside the basic multilingual plane; since json is assumed to be UTF-8, and we already force the encoding to UTF-8, simply pass through the un-encoded characters.

    Brett Carter

  • Deprecate Time.time_with_date_fallback, Time.utc_timeand Time.local_time. These methods were added to handle the limited range of Ruby's native Timeimplementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.

    Andrew White

  • Deprecate Date#to_time_in_current_zoneand add Date#in_time_zone. Andrew White

  • Add String#in_time_zonemethod to convert a string to an ActiveSupport::TimeWithZone. Andrew White

  • Deprecate ActiveSupport::BasicObjectin favor of ActiveSupport::ProxyObject. This class is used for proxy classes. It avoids confusion with Ruby's BasicObject class.

    Francesco Rodriguez

  • Patched Marshal#loadto work with constant autoloading. Fixes autoloading with cache stores that rely on Marshal ( MemCacheStoreand FileStore). Fixes #8167.

    Uriel Katz

  • Make Time.zone.parseto work with JavaScript format date strings. Andrew White

  • Add DateTime#seconds_until_end_of_dayand Time#seconds_until_end_of_dayas a complement for seconds_from_midnight; useful when setting expiration times for caches, e.g.:

    <% cache('dashboard', expires_in: Date.current.seconds_until_end_of_day) do %>

    Olek Janiszewski

  • No longer proxy ActiveSupport::Multibyte#class. Steve Klabnik

  • Deprecate ActiveSupport::TestCase#pendingmethod, use skipfrom minitest instead. Carlos Antonio da Silva

  • XmlMini.with_backendnow may be safely used with threads:

    Thread.new do
      XmlMini.with_backend("REXML") { rexml_power }
    Thread.new do
      XmlMini.with_backend("LibXML") { libxml_power }

    Each thread will use it's own backend.

    Nikita Afanasenko

  • Dependencies no longer trigger Kernel#autoloadin remove_constant. Fixes #8213. Xavier Noria

  • Simplify mochaintegration and remove monkey-patches, bumping mochato 0.13.0. James Mead

  • #as_jsonisolates options when encoding a hash. Fixes #8182.

    Yves Senn

  • Deprecate Hash#diffin favor of minitest's diff. Steve Klabnik

  • Kernel#capturecan catch output from subprocesses. Dmitry Vorotilin

  • to_xmlconversions now use builder's tag! method instead of explicit invocation of method_missing.

    Nikita Afanasenko

  • Fixed timezone mapping of the Solomon Islands. Steve Klabnik

  • Make callstack attribute optional in ActiveSupport::Deprecation::Reportingmethods warnand deprecation_warning.

    Alexey Gaziev

  • Implement HashWithIndifferentAccess#replaceso key?works correctly. David Graham

  • Handle the possible permission denied errors atomic.rbmight trigger due to its chownand chmodcalls.

    Daniele Sluijters

  • Hash#extract!returns only those keys that present in the receiver.

    {a: 1, b: 2}.extract!(:a, :x) # => {:a => 1}

    Mikhail Dieterle

  • Hash#extract!returns the same subclass, that the receiver is. I.e. HashWithIndifferentAccess#extract!returns a HashWithIndifferentAccessinstance.

    Mikhail Dieterle

  • Optimize ActiveSupport::Cache::Entryto reduce memory and processing overhead. Brian Durand

  • Tests tag the Rails log with the current test class and test case:

    [SessionsControllerTest] [test_0002_sign in] Processing by SessionsController#create as HTML
    [SessionsControllerTest] [test_0002_sign in] ...

    Jeremy Kemper

  • Add logger.push_tagsand .pop_tagsto complement logger.tagged:

    class Job
      def before
        Rails.logger.push_tags :jobs, self.class.name
      def after
        Rails.logger.pop_tags 2

    Jeremy Kemper

  • Allow delegation to the class using the :classkeyword, replacing self.classusage:

    class User
      def self.hello
      delegate :hello, to: :class

    Marc-Andre Lafortune

  • Date.beginning_of_weekthread local and beginning_of_weekapplication config option added (default is Monday).

    Innokenty Mikhailov

  • An optional block can be passed to config_accessorto set its default value

    class User
      include ActiveSupport::Configurable
      config_accessor :hair_colors do
        [:brown, :black, :blonde, :red]
    User.hair_colors # => [:brown, :black, :blonde, :red]

    Larry Lv

  • ActiveSupport::Benchmarkable#silencehas been deprecated due to its lack of thread safety. It will be removed without replacement in Rails 4.1.

    Steve Klabnik

  • An optional block can be passed to Hash#deep_merge. The block will be invoked for each duplicated key and used to resolve the conflict.

    Pranas Kiziela

  • ActiveSupport::Deprecationis now a class. It is possible to create an instance of deprecator. Backwards compatibility has been preserved.

    You can choose which instance of the deprecator will be used.

    deprecate :method_name, deprecator: deprecator_instance

    You can use ActiveSupport::Deprecationin your gem.

    require 'active_support/deprecation'
    require 'active_support/core_ext/module/deprecation'
    class MyGem
      def self.deprecator
        ActiveSupport::Deprecation.new('2.0', 'MyGem')
      def old_method
      def new_method
      deprecate old_method: :new_method, deprecator: deprecator
    # => DEPRECATION WARNING: old_method is deprecated and will be removed from MyGem 2.0 (use new_method instead). (called from <main> at file.rb:18)

    Piotr Niełacny & Robert Pankowecki

  • ERB::Util.html_escapeencodes single quote as #39. Decimal form has better support in old browsers. Kalys Osmonov

  • ActiveSupport::Callbacks: deprecate monkey patch of object callbacks. Using the filtermethod like this:

    before_filter MyFilter.new
    class MyFilter
      def filter(controller)

    Is now deprecated with recommendation to use the corresponding filter type ( #before, #afteror #around):

    before_filter MyFilter.new
    class MyFilter
      def before(controller)

    Bogdan Gusiev

  • An optional block can be passed to HashWithIndifferentAccess#updateand #merge. The block will be invoked for each duplicated key, and used to resolve the conflict, thus replicating the behaviour of the corresponding methods on the Hashclass.

    Leo Cassarani

  • Remove jalias for ERB::Util#json_escape. The jalias is already used for ActionView::Helpers::JavaScriptHelper#escape_javascriptand both modules are included in the view context that would confuse the developers.

    Akira Matsuda

  • Replace deprecated memcache-clientgem with dalli in ActiveSupport::Cache::MemCacheStore.

    Guillermo Iguaran

  • Add default values to all ActiveSupport::NumberHelpermethods, to avoid errors with empty locales or missing values.

    Carlos Antonio da Silva

  • ActiveSupport::JSON::Variableis deprecated. Define your own #as_jsonand #encode_jsonmethods for custom JSON string literals.

    Erich Menge

  • Add String#indent. fxn & Ace Suares

  • Inflections can now be defined per locale. singularizeand pluralizeaccept locale as an extra argument.

    David Celis

  • Object#trywill now return nilinstead of raise a NoMethodErrorif the receiving object does not implement the method, but you can still get the old behavior by using the new Object#try!.


  • ERB::Util.html_escapenow escapes single quotes. Santiago Pastorino

  • Time#changenow works with time values with offsets other than UTC or the local time zone. Andrew White

  • ActiveSupport::Callbacks: deprecate usage of filter object with #beforeand #aftermethods as aroundcallback. Bogdan Gusiev

  • Add Time#prev_quarterand Time#next_quarter short-hands for months_ago(3)and months_since(3). SungHee Kang

  • Remove obsolete and unused require_associationmethod from dependencies. fxn

  • Add :instance_accessoroption for config_accessor.

    class User
      include ActiveSupport::Configurable
      config_accessor :allowed_access, instance_accessor: false
    User.new.allowed_access = true # => NoMethodError
    User.new.allowed_access        # => NoMethodError

    Francesco Rodriguez

  • ActionView::Helpers::NumberHelpermethods have been moved to ActiveSupport::NumberHelperand are now available via Numeric#to_s. Numeric#to_snow accepts the formatting options :phone, :currency, :percentage, :delimited, :rounded, :human, and :human_size.

    Andrew Mutz

  • Add Hash#transform_keys, Hash#transform_keys!, Hash#deep_transform_keys, and Hash#deep_transform_keys!. Mark McSpadden

  • Changed XML type datetimeto dateTime(with upper case letter T). Angelo Capilleri

  • Add :instance_accessoroption for class_attribute. Alexey Vakhov

  • constantizenow looks in the ancestor chain. Marc-Andre Lafortune & Andrew White

  • Adds Hash#deep_stringify_keysand Hash#deep_stringify_keys!to convert all keys from a Hashinstance into strings. Lucas Húngaro

  • Adds Hash#deep_symbolize_keysand Hash#deep_symbolize_keys!to convert all keys from a Hashinstance into symbols. Lucas Húngaro

  • Object#trycan't call private methods. Vasiliy Ermolovich

  • AS::Callbacks#run_callbacksremove keyargument. Francesco Rodriguez

  • deep_dupworks more expectedly now and duplicates also values in Hashinstances and elements in Array instances. Alexey Gaziev

  • Inflector no longer applies ice -> ouse to words like "slice", "police", etc. Wes Morgan

  • Add ActiveSupport::Deprecations.behavior = :silenceto completely ignore Rails runtime deprecations. twinturbo

  • Make Module#delegatestop using send- can no longer delegate to private methods. dasch

  • ActiveSupport::Callbacks: deprecate :rescuable option. Bogdan Gusiev

  • Adds Integer#ordinalto get the ordinal suffix string of an integer. Tim Gildea

  • ActiveSupport::Callbacks: :per_keyoption is no longer supported. Bogdan Gusiev

  • ActiveSupport::Callbacks#define_callbacks: add :skip_after_callbacks_if_terminatedoption. Bogdan Gusiev

  • Add html_escape_onceto ERB::Util, and delegate the escape_oncetag helper to it. Carlos Antonio da Silva

  • Deprecates the compatibility method Module#local_constant_names, use Module#local_constantsinstead (which returns symbols). Xavier Noria

  • Deletes the compatibility method Module#method_names, use Module#methodsfrom now on (which returns symbols). Xavier Noria

  • Deletes the compatibility method Module#instance_method_names, use Module#instance_methodsfrom now on (which returns symbols). Xavier Noria

  • BufferedLoggeris deprecated. Use ActiveSupport::Logger, or the logger from the Ruby standard library.

    Aaron Patterson

  • Unicode database updated to 6.1.0. Norman Clarke

  • Adds encode_big_decimal_as_stringoption to force JSON serialization of BigDecimalas numeric instead of wrapping them in strings for safety.

  • Optimize log subscribers to check log level before doing any processing. Brian Durand

Please check 3-2-stable for previous changes.