Skip to content

Instantly share code, notes, and snippets.

Created December 13, 2011 13:35
Show Gist options
  • Save vijaydev/1472145 to your computer and use it in GitHub Desktop.
Save vijaydev/1472145 to your computer and use it in GitHub Desktop.
Rails 3.2.0 Changelogs

The latest release notes is available at

Railties 3.2.0 (unreleased)

  • Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting config.reload_classes_only_on_change to false. José Valim

  • New applications get a flag config.active_record.auto_explain_threshold_in_seconds in the environments configuration files. With a value of 0.5 in development.rb, and commented out in production.rb. No mention in test.rb. fxn

  • Add DebugExceptions middleware which contains features extracted from ShowExceptions middleware José Valim

  • Display mounted engine's routes in rake routes Piotr Sarnacki

  • Allow to change the loading order of railties with config.railties_order= Piotr Sarnacki

    Example: config.railties_order = [Blog::Engine, :main_app, :all]

  • Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box José Valim

  • Update Rails::Rack::Logger middleware to apply any tags set in config.log_tags to the newly ActiveSupport::TaggedLogging Rails.logger. This makes it easy to tag log lines with debug information like subdomain and request id -- both very helpful in debugging multi-user production applications DHH

  • Default options to rails new can be set in ~/.railsrc Guillermo Iguaran

  • Add destroy alias to Rails engines Guillermo Iguaran

  • Add destroy alias for Rails command line. This allows the following: rails d model post Andrey Ognevsky

  • Attributes on scaffold and model generators default to string. This allows the following: "rails g scaffold Post title body:text author" José Valim

  • Remove old plugin generator (rails generate plugin) in favor of rails plugin new command Guillermo Iguaran

  • Remove old '' API in favor of 'config.paths["app/controller"]' API Guillermo Iguaran

Active Model 3.2.0 (unreleased)

  • Deprecated define_attr_method in ActiveModel::AttributeMethods, because this only existed to support methods like set_table_name in Active Record, which are themselves being deprecated.

    Jon Leighton

  • Add ActiveModel::Errors#added? to check if a specific error has been added Martin Svalin

  • Add ability to define strict validation(with :strict => true option) that always raises exception when fails Bogdan Gusiev

  • Deprecate "Model.model_name.partial_path" in favor of "model.to_partial_path" Grant Hutchins, Peter Jaros

  • Provide mass_assignment_sanitizer as an easy API to replace the sanitizer behavior. Also support both :logger (default) and :strict sanitizer behavior Bogdan Gusiev

Action Pack 3.2.0 (unreleased)

  • Add button_tag support to ActionView::Helpers::FormBuilder.

    This support mimics the default behavior of submit_tag.


    <%= form_for @post do |f| %>
      <%= f.button %>
    <% end %>
  • Date helpers accept a new option, :use_two_digit_numbers = true, that renders select boxes for months and days with a leading zero without changing the respective values. For example, this is useful for displaying ISO8601-style dates such as '2011-08-01'. Lennart Fridén and Kim Persson

  • Make ActiveSupport::Benchmarkable a default module for ActionController::Base, so the #benchmark method is once again available in the controller context like it used to be DHH

  • Deprecated implied layout lookup in controllers whose parent had a explicit layout set:

    class ApplicationController
      layout "application"
    class PostsController < ApplicationController

    In the example above, Posts controller will no longer automatically look up for a posts layout.

    If you need this functionality you could either remove layout "application" from ApplicationController or explicitly set it to nil in PostsController. José Valim

  • Rails will now use your default layout (such as "layouts/application") when you specify a layout with :only and :except condition, and those conditions fail. Prem Sichanugrist

    For example, consider this snippet:

    class CarsController
      layout 'single_car', :only => :show

    Rails will use 'layouts/single_car' when a request comes in :show action, and use 'layouts/application' (or 'layouts/cars', if exists) when a request comes in for any other actions.

  • form_for with +:as+ option uses "#{action}_#{as}" as css class and id:


    form_for(@user, :as => 'client') # => "<form class="client_new">..."


    form_for(@user, :as => 'client') # => "<form class="new_client">..."

    Vasiliy Ermolovich

  • Allow rescue responses to be configured through a railtie as in config.action_dispatch.rescue_responses. Please look at ActiveRecord::Railtie for an example José Valim

  • Allow fresh_when/stale? to take a record instead of an options hash DHH

  • Assets should use the request protocol by default or default to relative if no request is available Jonathan del Strother

  • Log "Filter chain halted as CALLBACKNAME rendered or redirected" every time a before callback halts José Valim

  • You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generate HTML id. Vasiliy Ermolovich


    <%= form_for(@offer, :namespace => 'namespace') do |f| %>
      <%= f.label :version, 'Version' %>:
      <%= f.text_field :version %>
    <% end %>
  • Refactor ActionDispatch::ShowExceptions. Controller is responsible for choice to show exceptions. Sergey Nartimov

    It's possible to override +show_detailed_exceptions?+ in controllers to specify which requests should provide debugging information on errors.

  • Responders now return 204 No Content for API requests without a response body (as in the new scaffold) José Valim

  • Added ActionDispatch::RequestId middleware that'll make a unique X-Request-Id header available to the response and enables the ActionDispatch::Request#uuid method. This makes it easy to trace requests from end-to-end in the stack and to identify individual requests in mixed logs like Syslog DHH

  • Limit the number of options for select_year to 1000.

    Pass the :max_years_allowed option to set your own limit.

    Libo Cannici

  • Passing formats or handlers to render :template and friends is deprecated. For example: Nick Sutterer & José Valim

    render :template => "foo.html.erb"

    Instead, you can provide :handlers and :formats directly as option: render :template => "foo", :formats => [:html, :js], :handlers => :erb

  • Changed log level of warning for missing CSRF token from :debug to :warn. Mike Dillon

  • content_tag_for and div_for can now take the collection of records. It will also yield the record as the first argument if you set a receiving argument in your block Prem Sichanugrist

    So instead of having to do this:

    @items.each do |item|
      content_tag_for(:li, item) do
         Title: <%= item.title %>

    You can now do this:

    content_tag_for(:li, @items) do |item|
      Title: <%= item.title %>
  • send_file now guess the mime type Esad Hajdarevic

  • Mime type entries for PDF, ZIP and other formats were added Esad Hajdarevic

  • Generate hidden input before select with :multiple option set to true. This is useful when you rely on the fact that when no options is set, the state of select will be sent to rails application. Without hidden field nothing is sent according to HTML spec Bogdan Gusiev

  • Refactor ActionController::TestCase cookies Andrew White

    Assigning cookies for test cases should now use cookies[], e.g:

    cookies[:email] = ''
    get :index
    assert_equal '', cookies[:email]

    To clear the cookies, use clear, e.g:

    get :index
    assert_nil cookies[:email]

    We now no longer write out HTTP_COOKIE and the cookie jar is persistent between requests so if you need to manipulate the environment for your test you need to do it before the cookie jar is created.

  • ActionController::ParamsWrapper on ActiveRecord models now only wrap attr_accessible attributes if they were set, if not, only the attributes returned by the class method attribute_names will be wrapped. This fixes the wrapping of nested attributes by adding them to attr_accessible.

Active Resource 3.2.0 (unreleased)

  • Redirect responses: 303 See Other and 307 Temporary Redirect now behave like 301 Moved Permanently and 302 Found. GH #3302.

    Jim Herz

ActiveSupport 3.2.0 (unreleased)

  • Added Enumerable#pluck to wrap the common pattern of collect(&:method) DHH

  • Module#synchronize is deprecated with no replacement. Please use monitor from ruby's standard library.

  • (Date|DateTime|Time)#beginning_of_week accept an optional argument to be able to set the day at which weeks are assumed to start.

  • Deprecated ActiveSupport::MessageEncryptor#encrypt and decrypt. José Valim

  • ActiveSupport::Notifications.subscribed provides subscriptions to events while a block runs. fxn

  • Module#qualified_const_(defined?|get|set) are analogous to the corresponding methods in the standard API, but accept qualified constant names. fxn

  • Added inflection #deconstantize which complements #demodulize. This inflection removes the righmost segment in a qualified constant name. fxn

  • Added ActiveSupport:TaggedLogging that can wrap any standard Logger class to provide tagging capabilities DHH

    Logger =
    Logger.tagged("BCX") { "Stuff" }                            # Logs "[BCX] Stuff"
    Logger.tagged("BCX", "Jason") { "Stuff" }                   # Logs "[BCX] [Jason] Stuff"
    Logger.tagged("BCX") { Logger.tagged("Jason") { "Stuff" } } # Logs "[BCX] [Jason] Stuff"
  • Added safe_constantize that constantizes a string but returns nil instead of an exception if the constant (or part of it) does not exist Ryan Oblak

  • ActiveSupport::OrderedHash is now marked as extractable when using Array#extract_options! Prem Sichanugrist

  • Added Array#prepend as an alias for Array#unshift and Array#append as an alias for Array#<< DHH

  • The definition of blank string for Ruby 1.9 has been extended to Unicode whitespace. Also, in 1.8 the ideographic space U+3000 is considered to be whitespace. Akira Matsuda, Damien Mathieu

  • The inflector understands acronyms. dlee

  • Deprecated ActiveSupport::Memoizable in favor of Ruby memoization pattern José Valim

  • Added Time#all_day/week/quarter/year as a way of generating ranges (example: Event.where(created_at: DHH

  • Added instance_accessor: false as an option to Class#cattr_accessor and friends DHH

  • Removed ActiveSupport::SecureRandom in favor of SecureRandom from the standard library Jon Leighton

  • ActiveSupport::OrderedHash now has different behavior for #each and #each_pair when given a block accepting its parameters with a splat. Andrew Radev

  • ActiveSupport::BufferedLogger#silence is deprecated. If you want to squelch logs for a certain block, change the log level for that block.

  • ActiveSupport::BufferedLogger#open_log is deprecated. This method should not have been public in the first place.

  • ActiveSupport::BufferedLogger's behavior of automatically creating the directory for your log file is deprecated. Please make sure to create the directory for your log file before instantiating.

  • ActiveSupport::BufferedLogger#auto_flushing is deprecated. Either set the sync level on the underlying file handle like this:

    f ='foo.log', 'w')
    f.sync = true f

    Or tune your filesystem. The FS cache is now what controls flushing.

  • ActiveSupport::BufferedLogger#flush is deprecated. Set sync on your filehandle, or tune your filesystem.

Active Record 3.2.0 (unreleased)

  • Added ability to run migrations only for given scope, which allows to run migrations only from one engine (for example to revert changes from engine that you want to remove).

    Example: rake db:migrate SCOPE=blog

Piotr Sarnacki

  • Migrations copied from engines are now scoped with engine's name, for example Piotr Sarnacki

  • Implements AR::Base.silence_auto_explain. This method allows the user to selectively disable automatic EXPLAINs within a block. fxn

  • Implements automatic EXPLAIN logging for slow queries.

    A new configuration parameter config.active_record.auto_explain_threshold_in_seconds determines what's to be considered a slow query. Setting that to nil disables this feature. Defaults are 0.5 in development mode, and nil in test and production modes.

    As of this writing there's support for SQLite, MySQL (mysql2 adapter), and PostgreSQL.


  • Implemented ActiveRecord::Relation#pluck method

    Method returns Array of column value from table under ActiveRecord model


    Bogdan Gusiev

  • Automatic closure of connections in threads is deprecated. For example the following code is deprecated: { Post.find(1) }.join

    It should be changed to close the database connection at the end of the thread: { Post.find(1) Post.connection.close }.join

    Only people who spawn threads in their application code need to worry about this change.

  • Deprecated:

    • set_table_name
    • set_inheritance_column
    • set_sequence_name
    • set_primary_key
    • set_locking_column

    Use an assignment method instead. For example, instead of set_table_name, use self.table_name=:

     class Project < ActiveRecord::Base
       self.table_name = "project"

    Or define your own self.table_name method:

     class Post < ActiveRecord::Base
       def self.table_name
         "special_" + super
     Post.table_name # => "special_posts"

    Jon Leighton

  • Generated association methods are created within a separate module to allow overriding and composition using super. For a class named MyModel, the module is named MyModel::GeneratedFeatureMethods. It is included into the model class immediately after the generated_attributes_methods module defined in ActiveModel, so association methods override attribute methods of the same name. Josh Susser

  • Implemented ActiveRecord::Relation#explain. fxn

  • Add ActiveRecord::Relation#uniq for generating unique queries.

    Before:'DISTINCT name')


    This also allows you to revert the unqueness in a relation:

    Jon Leighton

  • Support index sort order in sqlite, mysql and postgres adapters. Vlad Jebelev

  • Allow the :class_name option for associations to take a symbol (:Client) in addition to a string ('Client').

    This is to avoid confusing newbies, and to be consistent with the fact that other options like :foreign_key already allow a symbol or a string.

    Jon Leighton

  • In development mode the db:drop task also drops the test database. For symmetry with the db:create task. Dmitriy Kiriyenko

  • Added for declaring simple single-column key/value stores DHH

    class User < ActiveRecord::Base
      store :settings, accessors: [ :color, :homepage ]
    u = 'black', homepage: '')
    u.color                          # Accessor stored attribute
    u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
  • MySQL: case-insensitive uniqueness validation avoids calling LOWER when the column already uses a case-insensitive collation. Fixes #561.

    Joseph Palermo

  • Transactional fixtures enlist all active database connections. You can test models on different connections without disabling transactional fixtures.

    Jeremy Kemper

  • Add first_or_create, first_or_create!, first_or_initialize methods to Active Record. This is a better approach over the old find_or_create_by dynamic methods because it's clearer which arguments are used to find the record and which are used to create it:

    User.where(:first_name => "Scarlett").first_or_create!(:last_name => "Johansson")

    Andrés Mejía

  • Fix nested attributes bug where _destroy parameter is taken into account during :reject_if => :all_blank (fixes #2937)

    Aaron Christy

  • Add ActiveSupport::Cache::NullStore for use in development and testing.

    Brian Durand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment