## Rails 3.2.1 (January 26, 2012) ##
* Documentation fixes.
* Migration generation understands decimal{1.2} and decimal{1-2}, in
addition to decimal{1,2}. *José Valim*
## Rails 3.2.0 (January 20, 2012) ##
* Rails 2.3-style plugins in vendor/plugins are deprecated and will be removed in Rails 4.0. Move them out of vendor/plugins and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. *Santiago Pastorino*
* Guides are available as a single .mobi for the Kindle and free Kindle readers apps. *Michael Pearson & Xavier Noria*
* Allow scaffold/model/migration generators to accept a "index" and "uniq" modifiers, as in: "tracking_id:integer:uniq" in order to generate (unique) indexes. Some types also accept custom options, for instance, you can specify the precision and scale for decimals as "price:decimal{7,2}". *Dmitrii Samoilov*
* Added `config.exceptions_app` to set the exceptions application invoked by the ShowException middleware when an exception happens. Defaults to `ActionDispatch::PublicExceptions.new(Rails.public_path)`. *José Valim*
* 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 'config.paths.app.controller' API in favor of 'config.paths["app/controller"]' API *Guillermo Iguaran*
## Rails 3.2.1 (January 26, 2012) ##
* The threshold for auto EXPLAIN is ignored if there's no logger. *fxn*
* Call `to_s` on the value passed to `table_name=`, in particular symbols
are supported (regression). *Sergey Nartimov*
* Fix possible race condition when two threads try to define attribute
methods for the same class. *Jon Leighton*
## Rails 3.2.0 (January 20, 2012) ##
* Added a `with_lock` method to ActiveRecord objects, which starts
a transaction, locks the object (pessimistically) and yields to the block.
The method takes one (optional) parameter and passes it to `lock!`.
Before:
class Order < ActiveRecord::Base
def cancel!
transaction do
lock!
# ... cancelling logic
end
end
end
After:
class Order < ActiveRecord::Base
def cancel!
with_lock do
# ... cancelling logic
end
end
end
*Olek Janiszewski*
* 'on' and 'ON' boolean columns values are type casted to true
*Santiago Pastorino*
* 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 01_create_posts.blog.rb. *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.
*fxn*
* Implemented ActiveRecord::Relation#pluck method
Method returns Array of column value from table under ActiveRecord model
Client.pluck(:id)
*Bogdan Gusiev*
* Automatic closure of connections in threads is deprecated. For example
the following code is deprecated:
Thread.new { Post.find(1) }.join
It should be changed to close the database connection at the end of
the thread:
Thread.new {
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"
end
Or define your own `self.table_name` method:
class Post < ActiveRecord::Base
def self.table_name
"special_" + super
end
end
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:
Client.select('DISTINCT name')
After:
Client.select(:name).uniq
This also allows you to revert the unqueness in a relation:
Client.select(:name).uniq.uniq(false)
*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 ActiveRecord::Base.store for declaring simple single-column key/value stores *DHH*
class User < ActiveRecord::Base
store :settings, accessors: [ :color, :homepage ]
end
u = User.new(color: 'black', homepage: '37signals.com')
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*
## Rails 3.2.2 (unreleased) ##
* Format lookup for partials is derived from the format in which the template is being rendered. Closes#5025 part 2 *Santiago Pastorino*
* Use the right format when a partial is missing. Closes#5025. *Santiago Pastorino*
* Default responder will now always use your overridden block in `respond_with` to render your response. *Prem Sichanugrist*
* check_box helper with :disabled => true will generate a disabled hidden field to conform with the HTML convention where disabled fields are not submitted with the form.
This is a behavior change, previously the hidden tag had a value of the disabled checkbox.
*Tadas Tamosauskas*
## Rails 3.2.1 (January 26, 2012) ##
* Documentation improvements.
* Allow `form.select` to accept ranges (regression). *Jeremy Walker*
* `datetime_select` works with -/+ infinity dates. *Joe Van Dyk*
## Rails 3.2.0 (January 20, 2012) ##
* Setting config.assets.logger to false turn off Sprockets logger *Guillermo Iguaran*
* Add `config.action_dispatch.default_charset` to configure default charset for ActionDispatch::Response. *Carlos Antonio da Silva*
* Deprecate setting default charset at controller level, use the new `config.action_dispatch.default_charset` instead. *Carlos Antonio da Silva*
* Deprecate ActionController::UnknownAction in favour of AbstractController::ActionNotFound. *Carlos Antonio da Silva*
* Deprecate ActionController::DoubleRenderError in favour of AbstractController::DoubleRenderError. *Carlos Antonio da Silva*
* Deprecate method_missing handling for not found actions, use action_missing instead. *Carlos Antonio da Silva*
* Deprecate ActionController#rescue_action, ActionController#initialize_template_class, and ActionController#assign_shortcuts.
These methods were not being used internally anymore and are going to be removed in Rails 4. *Carlos Antonio da Silva*
* Add config.assets.logger to configure Sprockets logger *Rafael França*
* Use a BodyProxy instead of including a Module that responds to
close. Closes#4441 if Active Record is disabled assets are delivered
correctly *Santiago Pastorino*
* Rails initialization with initialize_on_precompile = false should set assets_dir *Santiago Pastorino*
* Add font_path helper method *Santiago Pastorino*
* Depends on rack ~> 1.4.0 *Santiago Pastorino*
* Add :gzip option to `caches_page`. The default option can be configured globally using `page_cache_compression` *Andrey Sitnik*
* The ShowExceptions middleware now accepts a exceptions application that is responsible to render an exception when the application fails. The application is invoked with a copy of the exception in `env["action_dispatch.exception"]` and with the PATH_INFO rewritten to the status code. *José Valim*
* Add `button_tag` support to ActionView::Helpers::FormBuilder.
This support mimics the default behavior of `submit_tag`.
Example:
<%= 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"
end
class PostsController < ApplicationController
end
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
end
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:
Before:
form_for(@user, :as => 'client') # => "<form class="client_new">..."
Now:
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*
Example:
<%= form_for(@offer, :namespace => 'namespace') do |f| %>
<%= f.label :version, 'Version' %>:
<%= f.text_field :version %>
<% end %>
* Refactor ActionDispatch::ShowExceptions. The controller is responsible for choosing to show exceptions when `consider_all_requests_local` is false.
It's possible to override `show_detailed_exceptions?` in controllers to specify which requests should provide debugging information on errors. The default value is now false, meaning local requests in production will no longer show the detailed exceptions page unless `show_detailed_exceptions?` is overridden and set to `request.local?`.
* 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 %>
end
end
You can now do this:
content_tag_for(:li, @items) do |item|
Title: <%= item.title %>
end
* 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] = 'user@example.com'
get :index
assert_equal 'user@example.com', cookies[:email]
To clear the cookies, use clear, e.g:
cookies.clear
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.
## Rails 3.2.1 (January 26, 2012) ##
* No changes.
## Rails 3.2.0 (January 20, 2012) ##
* 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*
## Rails 3.2.1 (January 26, 2012) ##
* Documentation fixes and improvements.
* Update time zone offset information. *Ravil Bayramgalin*
* The deprecated `ActiveSupport::Base64.decode64` calls `::Base64.decode64`
now. *Jonathan Viney*
* Fixes uninitialized constant `ActiveSupport::TaggedLogging::ERROR`. *kennyj*
## Rails 3.2.0 (January 20, 2012) ##
* ActiveSupport::Base64 is deprecated in favor of ::Base64. *Sergey Nartimov*
* 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 = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
Logger.tagged("BCX") { Logger.info "Stuff" } # Logs "[BCX] Stuff"
Logger.tagged("BCX", "Jason") { Logger.info "Stuff" } # Logs "[BCX] [Jason] Stuff"
Logger.tagged("BCX") { Logger.tagged("Jason") { Logger.info "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: Time.now.all_week)) *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 = File.open('foo.log', 'w')
f.sync = true
ActiveSupport::BufferedLogger.new 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.
Tweak COMMENT.
## Rails 3.1.4 (unreleased) ##
* Setting config.force_ssl also marks the session cookie as secure.
*José Valim*
* Add therubyrhino to Gemfile in new applications when running under JRuby.
*Guillermo Iguaran*
Tweak COMMENT.
## Rails 3.1.4 (unreleased) ##
* Fix a custom primary key regression *GH 3987*
*Jon Leighton*
* Perf fix (second try): don't load records for `has many :dependent =>
:delete_all` *GH 3672*
*Jon Leighton*
* Fix accessing `proxy_association` method from an association extension
where the calls are chained. *GH #3890*
(E.g. `post.comments.where(bla).my_proxy_method`)
*Jon Leighton*
* Perf fix: MySQL primary key lookup was still slow for very large
tables. *GH 3678*
*Kenny J*
* Perf fix: If a table has no primary key, don't repeatedly ask the database
for it.
*Julius de Bruijn*
Tweak COMMENT.
## Rails 3.1.4 (unreleased) ##
* Skip assets group in Gemfile and all assets configurations options
when the application is generated with --skip-sprockets option.
*Guillermo Iguaran*
* Use ProcessedAsset#pathname in Sprockets helpers when debugging is on.
Closes#3333#3348#3361.
*Guillermo Iguaran*
* Allow to use asset_path on named_routes aliasing RailsHelper's
asset_path to path_to_asset *Adrian Pike*
* Assets should use the request protocol by default or default to relative
if no request is available *Jonathan del Strother*
pkgsrc change:
* Tweak COMMENT.
*Rails 3.0.12 (unreleased)*
* Fix using `tranlate` helper with a html translation which uses the `:count`
option for pluralization.
*Jon Leighton*