Permalink
Browse files

Convert legacy release notes to Markdown

  • Loading branch information...
1 parent 5e13625 commit 7a0dad25f3be77211160560dc76a8f37963051d7 @sikachu sikachu committed Sep 7, 2012
View
383 guides/source/2_2_release_notes.md
@@ -1,69 +1,73 @@
-h2. Ruby on Rails 2.2 Release Notes
+Ruby on Rails 2.2 Release Notes
+===============================
-Rails 2.2 delivers a number of new and improved features. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the "list of commits":http://github.com/rails/rails/commits/master in the main Rails repository on GitHub.
+Rails 2.2 delivers a number of new and improved features. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the [list of commits](http://github.com/rails/rails/commits/master) in the main Rails repository on GitHub.
-Along with Rails, 2.2 marks the launch of the "Ruby on Rails Guides":http://guides.rubyonrails.org/, the first results of the ongoing "Rails Guides hackfest":http://hackfest.rubyonrails.org/guide. This site will deliver high-quality documentation of the major features of Rails.
+Along with Rails, 2.2 marks the launch of the [Ruby on Rails Guides](http://guides.rubyonrails.org/), the first results of the ongoing [Rails Guides hackfest](http://hackfest.rubyonrails.org/guide). This site will deliver high-quality documentation of the major features of Rails.
-endprologue.
+--------------------------------------------------------------------------------
-h3. Infrastructure
+Infrastructure
+--------------
Rails 2.2 is a significant release for the infrastructure that keeps Rails humming along and connected to the rest of the world.
-h4. Internationalization
+### Internationalization
Rails 2.2 supplies an easy system for internationalization (or i18n, for those of you tired of typing).
* Lead Contributors: Rails i18 Team
* More information :
-** "Official Rails i18 website":http://rails-i18n.org
-** "Finally. Ruby on Rails gets internationalized":http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized
-** "Localizing Rails : Demo application":http://github.com/clemens/i18n_demo_app
+ * [Official Rails i18 website](http://rails-i18n.org)
+ * [Finally. Ruby on Rails gets internationalized](http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized)
+ * [Localizing Rails : Demo application](http://github.com/clemens/i18n_demo_app)
-h4. Compatibility with Ruby 1.9 and JRuby
+### Compatibility with Ruby 1.9 and JRuby
Along with thread safety, a lot of work has been done to make Rails work well with JRuby and the upcoming Ruby 1.9. With Ruby 1.9 being a moving target, running edge Rails on edge Ruby is still a hit-or-miss proposition, but Rails is ready to make the transition to Ruby 1.9 when the latter is released.
-h3. Documentation
-
-The internal documentation of Rails, in the form of code comments, has been improved in numerous places. In addition, the "Ruby on Rails Guides":http://guides.rubyonrails.org/ project is the definitive source for information on major Rails components. In its first official release, the Guides page includes:
-
-* "Getting Started with Rails":http://guides.rubyonrails.org/getting_started.html
-* "Rails Database Migrations":http://guides.rubyonrails.org/migrations.html
-* "Active Record Associations":http://guides.rubyonrails.org/association_basics.html
-* "Active Record Query Interface":http://guides.rubyonrails.org/active_record_querying.html
-* "Layouts and Rendering in Rails":http://guides.rubyonrails.org/layouts_and_rendering.html
-* "Action View Form Helpers":http://guides.rubyonrails.org/form_helpers.html
-* "Rails Routing from the Outside In":http://guides.rubyonrails.org/routing.html
-* "Action Controller Overview":http://guides.rubyonrails.org/action_controller_overview.html
-* "Rails Caching":http://guides.rubyonrails.org/caching_with_rails.html
-* "A Guide to Testing Rails Applications":http://guides.rubyonrails.org/testing.html
-* "Securing Rails Applications":http://guides.rubyonrails.org/security.html
-* "Debugging Rails Applications":http://guides.rubyonrails.org/debugging_rails_applications.html
-* "Performance Testing Rails Applications":http://guides.rubyonrails.org/performance_testing.html
-* "The Basics of Creating Rails Plugins":http://guides.rubyonrails.org/plugins.html
+Documentation
+-------------
+
+The internal documentation of Rails, in the form of code comments, has been improved in numerous places. In addition, the [Ruby on Rails Guides](http://guides.rubyonrails.org/) project is the definitive source for information on major Rails components. In its first official release, the Guides page includes:
+
+* [Getting Started with Rails](http://guides.rubyonrails.org/getting_started.html)
+* [Rails Database Migrations](http://guides.rubyonrails.org/migrations.html)
+* [Active Record Associations](http://guides.rubyonrails.org/association_basics.html)
+* [Active Record Query Interface](http://guides.rubyonrails.org/active_record_querying.html)
+* [Layouts and Rendering in Rails](http://guides.rubyonrails.org/layouts_and_rendering.html)
+* [Action View Form Helpers](http://guides.rubyonrails.org/form_helpers.html)
+* [Rails Routing from the Outside In](http://guides.rubyonrails.org/routing.html)
+* [Action Controller Overview](http://guides.rubyonrails.org/action_controller_overview.html)
+* [Rails Caching](http://guides.rubyonrails.org/caching_with_rails.html)
+* [A Guide to Testing Rails Applications](http://guides.rubyonrails.org/testing.html)
+* [Securing Rails Applications](http://guides.rubyonrails.org/security.html)
+* [Debugging Rails Applications](http://guides.rubyonrails.org/debugging_rails_applications.html)
+* [Performance Testing Rails Applications](http://guides.rubyonrails.org/performance_testing.html)
+* [The Basics of Creating Rails Plugins](http://guides.rubyonrails.org/plugins.html)
All told, the Guides provide tens of thousands of words of guidance for beginning and intermediate Rails developers.
If you want to generate these guides locally, inside your application:
-<ruby>
+```
rake doc:guides
-</ruby>
+```
-This will put the guides inside +Rails.root/doc/guides+ and you may start surfing straight away by opening +Rails.root/doc/guides/index.html+ in your favourite browser.
+This will put the guides inside `Rails.root/doc/guides` and you may start surfing straight away by opening `Rails.root/doc/guides/index.html` in your favourite browser.
-* Lead Contributors: "Rails Documentation Team":credits.html
-* Major contributions from "Xavier Noria":http://advogato.org/person/fxn/diary.html and "Hongli Lai":http://izumi.plan99.net/blog/.
+* Lead Contributors: [Rails Documentation Team](credits.html)
+* Major contributions from [Xavier Noria":http://advogato.org/person/fxn/diary.html and "Hongli Lai](http://izumi.plan99.net/blog/.)
* More information:
-** "Rails Guides hackfest":http://hackfest.rubyonrails.org/guide
-** "Help improve Rails documentation on Git branch":http://weblog.rubyonrails.org/2008/5/2/help-improve-rails-documentation-on-git-branch
+ * [Rails Guides hackfest](http://hackfest.rubyonrails.org/guide)
+ * [Help improve Rails documentation on Git branch](http://weblog.rubyonrails.org/2008/5/2/help-improve-rails-documentation-on-git-branch)
-h3. Better integration with HTTP : Out of the box ETag support
+Better integration with HTTP : Out of the box ETag support
+----------------------------------------------------------
Supporting the etag and last modified timestamp in HTTP headers means that Rails can now send back an empty response if it gets a request for a resource that hasn't been modified lately. This allows you to check whether a response needs to be sent at all.
-<ruby>
+```ruby
class ArticlesController < ApplicationController
def show_with_respond_to_block
@article = Article.find(params[:id])
@@ -93,58 +97,60 @@ class ArticlesController < ApplicationController
fresh_when(:last_modified => @article.published_at.utc, :etag => @article)
end
end
-</ruby>
+```
-h3. Thread Safety
+Thread Safety
+-------------
The work done to make Rails thread-safe is rolling out in Rails 2.2. Depending on your web server infrastructure, this means you can handle more requests with fewer copies of Rails in memory, leading to better server performance and higher utilization of multiple cores.
-To enable multithreaded dispatching in production mode of your application, add the following line in your +config/environments/production.rb+:
+To enable multithreaded dispatching in production mode of your application, add the following line in your `config/environments/production.rb`:
-<ruby>
+```ruby
config.threadsafe!
-</ruby>
+```
* More information :
-** "Thread safety for your Rails":http://m.onkey.org/2008/10/23/thread-safety-for-your-rails
-** "Thread safety project announcement":http://weblog.rubyonrails.org/2008/8/16/josh-peek-officially-joins-the-rails-core
-** "Q/A: What Thread-safe Rails Means":http://blog.headius.com/2008/08/qa-what-thread-safe-rails-means.html
+ * [Thread safety for your Rails](http://m.onkey.org/2008/10/23/thread-safety-for-your-rails)
+ * [Thread safety project announcement](http://weblog.rubyonrails.org/2008/8/16/josh-peek-officially-joins-the-rails-core)
+ * [Q/A: What Thread-safe Rails Means](http://blog.headius.com/2008/08/qa-what-thread-safe-rails-means.html)
-h3. Active Record
+Active Record
+-------------
There are two big additions to talk about here: transactional migrations and pooled database transactions. There's also a new (and cleaner) syntax for join table conditions, as well as a number of smaller improvements.
-h4. Transactional Migrations
+### Transactional Migrations
-Historically, multiple-step Rails migrations have been a source of trouble. If something went wrong during a migration, everything before the error changed the database and everything after the error wasn't applied. Also, the migration version was stored as having been executed, which means that it couldn't be simply rerun by +rake db:migrate:redo+ after you fix the problem. Transactional migrations change this by wrapping migration steps in a DDL transaction, so that if any of them fail, the entire migration is undone. In Rails 2.2, transactional migrations are supported on PostgreSQL out of the box. The code is extensible to other database types in the future - and IBM has already extended it to support the DB2 adapter.
+Historically, multiple-step Rails migrations have been a source of trouble. If something went wrong during a migration, everything before the error changed the database and everything after the error wasn't applied. Also, the migration version was stored as having been executed, which means that it couldn't be simply rerun by `rake db:migrate:redo` after you fix the problem. Transactional migrations change this by wrapping migration steps in a DDL transaction, so that if any of them fail, the entire migration is undone. In Rails 2.2, transactional migrations are supported on PostgreSQL out of the box. The code is extensible to other database types in the future - and IBM has already extended it to support the DB2 adapter.
-* Lead Contributor: "Adam Wiggins":http://adam.heroku.com/
+* Lead Contributor: [Adam Wiggins](http://adam.heroku.com/)
* More information:
-** "DDL Transactions":http://adam.heroku.com/past/2008/9/3/ddl_transactions/
-** "A major milestone for DB2 on Rails":http://db2onrails.com/2008/11/08/a-major-milestone-for-db2-on-rails/
+ * [DDL Transactions](http://adam.heroku.com/past/2008/9/3/ddl_transactions/)
+ * [A major milestone for DB2 on Rails](http://db2onrails.com/2008/11/08/a-major-milestone-for-db2-on-rails/)
-h4. Connection Pooling
+### Connection Pooling
-Connection pooling lets Rails distribute database requests across a pool of database connections that will grow to a maximum size (by default 5, but you can add a +pool+ key to your +database.yml+ to adjust this). This helps remove bottlenecks in applications that support many concurrent users. There's also a +wait_timeout+ that defaults to 5 seconds before giving up. +ActiveRecord::Base.connection_pool+ gives you direct access to the pool if you need it.
+Connection pooling lets Rails distribute database requests across a pool of database connections that will grow to a maximum size (by default 5, but you can add a `pool` key to your `database.yml` to adjust this). This helps remove bottlenecks in applications that support many concurrent users. There's also a `wait_timeout` that defaults to 5 seconds before giving up. `ActiveRecord::Base.connection_pool` gives you direct access to the pool if you need it.
-<ruby>
+```yaml
development:
adapter: mysql
username: root
database: sample_development
pool: 10
wait_timeout: 10
-</ruby>
+```
-* Lead Contributor: "Nick Sieger":http://blog.nicksieger.com/
+* Lead Contributor: [Nick Sieger](http://blog.nicksieger.com/)
* More information:
-** "What's New in Edge Rails: Connection Pools":http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-connection-pools
+ * [What's New in Edge Rails: Connection Pools](http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-connection-pools)
-h4. Hashes for Join Table Conditions
+### Hashes for Join Table Conditions
You can now specify conditions on join tables using a hash. This is a big help if you need to query across complex joins.
-<ruby>
+```ruby
class Photo < ActiveRecord::Base
belongs_to :product
end
@@ -155,268 +161,275 @@ end
# Get all products with copyright-free photos:
Product.all(:joins => :photos, :conditions => { :photos => { :copyright => false }})
-</ruby>
+```
* More information:
-** "What's New in Edge Rails: Easy Join Table Conditions":http://ryandaigle.com/articles/2008/7/7/what-s-new-in-edge-rails-easy-join-table-conditions
+ * [What's New in Edge Rails: Easy Join Table Conditions](http://ryandaigle.com/articles/2008/7/7/what-s-new-in-edge-rails-easy-join-table-conditions)
-h4. New Dynamic Finders
+### New Dynamic Finders
Two new sets of methods have been added to Active Record's dynamic finders family.
-h5. +find_last_by_<em>attribute</em>+
+#### `find_last_by_attribute`
-The +find_last_by_<em>attribute</em>+ method is equivalent to +Model.last(:conditions => {:attribute => value})+
+The `find_last_by_attribute` method is equivalent to `Model.last(:conditions => {:attribute => value})`
-<ruby>
+```ruby
# Get the last user who signed up from London
User.find_last_by_city('London')
-</ruby>
+```
-* Lead Contributor: "Emilio Tagua":http://www.workingwithrails.com/person/9147-emilio-tagua
+* Lead Contributor: [Emilio Tagua](http://www.workingwithrails.com/person/9147-emilio-tagua)
-h5. +find_by_<em>attribute</em>!+
+#### `find_by_attribute!`
-The new bang! version of +find_by_<em>attribute</em>!+ is equivalent to +Model.first(:conditions => {:attribute => value}) || raise ActiveRecord::RecordNotFound+ Instead of returning +nil+ if it can't find a matching record, this method will raise an exception if it cannot find a match.
+The new bang! version of `find_by_attribute!` is equivalent to `Model.first(:conditions => {:attribute => value}) || raise ActiveRecord::RecordNotFound` Instead of returning `nil` if it can't find a matching record, this method will raise an exception if it cannot find a match.
-<ruby>
+```ruby
# Raise ActiveRecord::RecordNotFound exception if 'Moby' hasn't signed up yet!
User.find_by_name!('Moby')
-</ruby>
+```
-* Lead Contributor: "Josh Susser":http://blog.hasmanythrough.com
+* Lead Contributor: [Josh Susser](http://blog.hasmanythrough.com)
-h4. Associations Respect Private/Protected Scope
+### Associations Respect Private/Protected Scope
-Active Record association proxies now respect the scope of methods on the proxied object. Previously (given User has_one :account) +@user.account.private_method+ would call the private method on the associated Account object. That fails in Rails 2.2; if you need this functionality, you should use +@user.account.send(:private_method)+ (or make the method public instead of private or protected). Please note that if you're overriding +method_missing+, you should also override +respond_to+ to match the behavior in order for associations to function normally.
+Active Record association proxies now respect the scope of methods on the proxied object. Previously (given User has_one :account) `@user.account.private_method` would call the private method on the associated Account object. That fails in Rails 2.2; if you need this functionality, you should use `@user.account.send(:private_method)` (or make the method public instead of private or protected). Please note that if you're overriding `method_missing`, you should also override `respond_to` to match the behavior in order for associations to function normally.
* Lead Contributor: Adam Milligan
* More information:
-** "Rails 2.2 Change: Private Methods on Association Proxies are Private":http://afreshcup.com/2008/10/24/rails-22-change-private-methods-on-association-proxies-are-private/
+ * [Rails 2.2 Change: Private Methods on Association Proxies are Private](http://afreshcup.com/2008/10/24/rails-22-change-private-methods-on-association-proxies-are-private/)
-h4. Other ActiveRecord Changes
+### Other ActiveRecord Changes
-* +rake db:migrate:redo+ now accepts an optional VERSION to target that specific migration to redo
-* Set +config.active_record.timestamped_migrations = false+ to have migrations with numeric prefix instead of UTC timestamp.
-* Counter cache columns (for associations declared with +:counter_cache => true+) do not need to be initialized to zero any longer.
-* +ActiveRecord::Base.human_name+ for an internationalization-aware humane translation of model names
+* `rake db:migrate:redo` now accepts an optional VERSION to target that specific migration to redo
+* Set `config.active_record.timestamped_migrations = false` to have migrations with numeric prefix instead of UTC timestamp.
+* Counter cache columns (for associations declared with `:counter_cache => true`) do not need to be initialized to zero any longer.
+* `ActiveRecord::Base.human_name` for an internationalization-aware humane translation of model names
-h3. Action Controller
+Action Controller
+-----------------
On the controller side, there are several changes that will help tidy up your routes. There are also some internal changes in the routing engine to lower memory usage on complex applications.
-h4. Shallow Route Nesting
+### Shallow Route Nesting
Shallow route nesting provides a solution to the well-known difficulty of using deeply-nested resources. With shallow nesting, you need only supply enough information to uniquely identify the resource that you want to work with.
-<ruby>
+```ruby
map.resources :publishers, :shallow => true do |publisher|
publisher.resources :magazines do |magazine|
magazine.resources :photos
end
end
-</ruby>
+```
This will enable recognition of (among others) these routes:
-<ruby>
+```
/publishers/1 ==> publisher_path(1)
/publishers/1/magazines ==> publisher_magazines_path(1)
/magazines/2 ==> magazine_path(2)
/magazines/2/photos ==> magazines_photos_path(2)
/photos/3 ==> photo_path(3)
-</ruby>
+```
-* Lead Contributor: "S. Brent Faulkner":http://www.unwwwired.net/
+* Lead Contributor: [S. Brent Faulkner](http://www.unwwwired.net/)
* More information:
-** "Rails Routing from the Outside In":http://guides.rubyonrails.org/routing.html#nested-resources
-** "What's New in Edge Rails: Shallow Routes":http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-shallow-routes
+ * [Rails Routing from the Outside In](http://guides.rubyonrails.org/routing.html#nested-resources)
+ * [What's New in Edge Rails: Shallow Routes](http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-shallow-routes)
-h4. Method Arrays for Member or Collection Routes
+### Method Arrays for Member or Collection Routes
You can now supply an array of methods for new member or collection routes. This removes the annoyance of having to define a route as accepting any verb as soon as you need it to handle more than one. With Rails 2.2, this is a legitimate route declaration:
-<ruby>
+```ruby
map.resources :photos, :collection => { :search => [:get, :post] }
-</ruby>
+```
-* Lead Contributor: "Brennan Dunn":http://brennandunn.com/
+* Lead Contributor: [Brennan Dunn](http://brennandunn.com/)
-h4. Resources With Specific Actions
+### Resources With Specific Actions
-By default, when you use +map.resources+ to create a route, Rails generates routes for seven default actions (index, show, create, new, edit, update, and destroy). But each of these routes takes up memory in your application, and causes Rails to generate additional routing logic. Now you can use the +:only+ and +:except+ options to fine-tune the routes that Rails will generate for resources. You can supply a single action, an array of actions, or the special +:all+ or +:none+ options. These options are inherited by nested resources.
+By default, when you use `map.resources` to create a route, Rails generates routes for seven default actions (index, show, create, new, edit, update, and destroy). But each of these routes takes up memory in your application, and causes Rails to generate additional routing logic. Now you can use the `:only` and `:except` options to fine-tune the routes that Rails will generate for resources. You can supply a single action, an array of actions, or the special `:all` or `:none` options. These options are inherited by nested resources.
-<ruby>
+```ruby
map.resources :photos, :only => [:index, :show]
map.resources :products, :except => :destroy
-</ruby>
+```
-* Lead Contributor: "Tom Stuart":http://experthuman.com/
+* Lead Contributor: [Tom Stuart](http://experthuman.com/)
-h4. Other Action Controller Changes
+### Other Action Controller Changes
-* You can now easily "show a custom error page":http://m.onkey.org/2008/7/20/rescue-from-dispatching for exceptions raised while routing a request.
-* The HTTP Accept header is disabled by default now. You should prefer the use of formatted URLs (such as +/customers/1.xml+) to indicate the format that you want. If you need the Accept headers, you can turn them back on with +config.action_controller.use_accept_header = true+.
+* You can now easily [show a custom error page](http://m.onkey.org/2008/7/20/rescue-from-dispatching) for exceptions raised while routing a request.
+* The HTTP Accept header is disabled by default now. You should prefer the use of formatted URLs (such as `/customers/1.xml`) to indicate the format that you want. If you need the Accept headers, you can turn them back on with `config.action_controller.use_accept_header = true`.
* Benchmarking numbers are now reported in milliseconds rather than tiny fractions of seconds
* Rails now supports HTTP-only cookies (and uses them for sessions), which help mitigate some cross-site scripting risks in newer browsers.
-* +redirect_to+ now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
-* +render+ now supports a +:js+ option to render plain vanilla JavaScript with the right mime type.
+* `redirect_to` now fully supports URI schemes (so, for example, you can redirect to a svn`ssh: URI).
+* `render` now supports a `:js` option to render plain vanilla JavaScript with the right mime type.
* Request forgery protection has been tightened up to apply to HTML-formatted content requests only.
-* Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling +polymorphic_path([@project, @date, @area])+ with a nil date will give you +project_area_path+.
+* Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling `polymorphic_path([@project, @date, @area])` with a nil date will give you `project_area_path`.
-h3. Action View
+Action View
+-----------
-* +javascript_include_tag+ and +stylesheet_link_tag+ support a new +:recursive+ option to be used along with +:all+, so that you can load an entire tree of files with a single line of code.
+* `javascript_include_tag` and `stylesheet_link_tag` support a new `:recursive` option to be used along with `:all`, so that you can load an entire tree of files with a single line of code.
* The included Prototype JavaScript library has been upgraded to version 1.6.0.3.
-* +RJS#page.reload+ to reload the browser's current location via JavaScript
-* The +atom_feed+ helper now takes an +:instruct+ option to let you insert XML processing instructions.
+* `RJS#page.reload` to reload the browser's current location via JavaScript
+* The `atom_feed` helper now takes an `:instruct` option to let you insert XML processing instructions.
-h3. Action Mailer
+Action Mailer
+-------------
-Action Mailer now supports mailer layouts. You can make your HTML emails as pretty as your in-browser views by supplying an appropriately-named layout - for example, the +CustomerMailer+ class expects to use +layouts/customer_mailer.html.erb+.
+Action Mailer now supports mailer layouts. You can make your HTML emails as pretty as your in-browser views by supplying an appropriately-named layout - for example, the `CustomerMailer` class expects to use `layouts/customer_mailer.html.erb`.
* More information:
-** "What's New in Edge Rails: Mailer Layouts":http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-mailer-layouts
+ * [What's New in Edge Rails: Mailer Layouts](http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-mailer-layouts)
Action Mailer now offers built-in support for GMail's SMTP servers, by turning on STARTTLS automatically. This requires Ruby 1.8.7 to be installed.
-h3. Active Support
+Active Support
+--------------
-Active Support now offers built-in memoization for Rails applications, the +each_with_object+ method, prefix support on delegates, and various other new utility methods.
+Active Support now offers built-in memoization for Rails applications, the `each_with_object` method, prefix support on delegates, and various other new utility methods.
-h4. Memoization
+### Memoization
Memoization is a pattern of initializing a method once and then stashing its value away for repeat use. You've probably used this pattern in your own applications:
-<ruby>
+```ruby
def full_name
@full_name ||= "#{first_name} #{last_name}"
end
-</ruby>
+```
Memoization lets you handle this task in a declarative fashion:
-<ruby>
+```ruby
extend ActiveSupport::Memoizable
def full_name
"#{first_name} #{last_name}"
end
memoize :full_name
-</ruby>
+```
-Other features of memoization include +unmemoize+, +unmemoize_all+, and +memoize_all+ to turn memoization on or off.
+Other features of memoization include `unmemoize`, `unmemoize_all`, and `memoize_all` to turn memoization on or off.
-* Lead Contributor: "Josh Peek":http://joshpeek.com/
+* Lead Contributor: [Josh Peek](http://joshpeek.com/)
* More information:
-** "What's New in Edge Rails: Easy Memoization":http://ryandaigle.com/articles/2008/7/16/what-s-new-in-edge-rails-memoization
-** "Memo-what? A Guide to Memoization":http://www.railway.at/articles/2008/09/20/a-guide-to-memoization
+ * [What's New in Edge Rails: Easy Memoization](http://ryandaigle.com/articles/2008/7/16/what-s-new-in-edge-rails-memoization)
+ * [Memo-what? A Guide to Memoization](http://www.railway.at/articles/2008/09/20/a-guide-to-memoization)
-h4. each_with_object
+### each_with_object
-The +each_with_object+ method provides an alternative to +inject+, using a method backported from Ruby 1.9. It iterates over a collection, passing the current element and the memo into the block.
+The `each_with_object` method provides an alternative to `inject`, using a method backported from Ruby 1.9. It iterates over a collection, passing the current element and the memo into the block.
-<ruby>
+```ruby
%w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } #=> {'foo' => 'FOO', 'bar' => 'BAR'}
-</ruby>
+```
-Lead Contributor: "Adam Keys":http://therealadam.com/
+Lead Contributor: [Adam Keys](http://therealadam.com/)
-h4. Delegates With Prefixes
+### Delegates With Prefixes
If you delegate behavior from one class to another, you can now specify a prefix that will be used to identify the delegated methods. For example:
-<ruby>
+```ruby
class Vendor < ActiveRecord::Base
has_one :account
delegate :email, :password, :to => :account, :prefix => true
end
-</ruby>
+```
-This will produce delegated methods +vendor#account_email+ and +vendor#account_password+. You can also specify a custom prefix:
+This will produce delegated methods `vendor#account_email` and `vendor#account_password`. You can also specify a custom prefix:
-<ruby>
+```ruby
class Vendor < ActiveRecord::Base
has_one :account
delegate :email, :password, :to => :account, :prefix => :owner
end
-</ruby>
+```
-This will produce delegated methods +vendor#owner_email+ and +vendor#owner_password+.
+This will produce delegated methods `vendor#owner_email` and `vendor#owner_password`.
-Lead Contributor: "Daniel Schierbeck":http://workingwithrails.com/person/5830-daniel-schierbeck
+Lead Contributor: [Daniel Schierbeck](http://workingwithrails.com/person/5830-daniel-schierbeck)
-h4. Other Active Support Changes
+### Other Active Support Changes
-* Extensive updates to +ActiveSupport::Multibyte+, including Ruby 1.9 compatibility fixes.
-* The addition of +ActiveSupport::Rescuable+ allows any class to mix in the +rescue_from+ syntax.
-* +past?+, +today?+ and +future?+ for +Date+ and +Time+ classes to facilitate date/time comparisons.
-* +Array#second+ through +Array#fifth+ as aliases for +Array#[1]+ through +Array#[4]+
-* +Enumerable#many?+ to encapsulate +collection.size > 1+
-* +Inflector#parameterize+ produces a URL-ready version of its input, for use in +to_param+.
-* +Time#advance+ recognizes fractional days and weeks, so you can do +1.7.weeks.ago+, +1.5.hours.since+, and so on.
+* Extensive updates to `ActiveSupport::Multibyte`, including Ruby 1.9 compatibility fixes.
+* The addition of `ActiveSupport::Rescuable` allows any class to mix in the `rescue_from` syntax.
+* `past?`, `today?` and `future?` for `Date` and `Time` classes to facilitate date/time comparisons.
+* `Array#second` through `Array#fifth` as aliases for `Array#[1]` through `Array#[4]`
+* `Enumerable#many?` to encapsulate `collection.size > 1`
+* `Inflector#parameterize` produces a URL-ready version of its input, for use in `to_param`.
+* `Time#advance` recognizes fractional days and weeks, so you can do `1.7.weeks.ago`, `1.5.hours.since`, and so on.
* The included TzInfo library has been upgraded to version 0.3.12.
-* +ActiveSuport::StringInquirer+ gives you a pretty way to test for equality in strings: +ActiveSupport::StringInquirer.new("abc").abc? => true+
+* `ActiveSuport::StringInquirer` gives you a pretty way to test for equality in strings: `ActiveSupport::StringInquirer.new("abc").abc? => true`
-h3. Railties
+Railties
+--------
-In Railties (the core code of Rails itself) the biggest changes are in the +config.gems+ mechanism.
+In Railties (the core code of Rails itself) the biggest changes are in the `config.gems` mechanism.
-h4. config.gems
+### config.gems
-To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in +/vendor/gems+. This capability first appeared in Rails 2.1, but it's much more flexible and robust in Rails 2.2, handling complicated dependencies between gems. Gem management in Rails includes these commands:
+To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in `/vendor/gems`. This capability first appeared in Rails 2.1, but it's much more flexible and robust in Rails 2.2, handling complicated dependencies between gems. Gem management in Rails includes these commands:
-* +config.gem _gem_name_+ in your +config/environment.rb+ file
-* +rake gems+ to list all configured gems, as well as whether they (and their dependencies) are installed, frozen, or framework (framework gems are those loaded by Rails before the gem dependency code is executed; such gems cannot be frozen)
-* +rake gems:install+ to install missing gems to the computer
-* +rake gems:unpack+ to place a copy of the required gems into +/vendor/gems+
-* +rake gems:unpack:dependencies+ to get copies of the required gems and their dependencies into +/vendor/gems+
-* +rake gems:build+ to build any missing native extensions
-* +rake gems:refresh_specs+ to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
+* `config.gem _gem_name_` in your `config/environment.rb` file
+* `rake gems` to list all configured gems, as well as whether they (and their dependencies) are installed, frozen, or framework (framework gems are those loaded by Rails before the gem dependency code is executed; such gems cannot be frozen)
+* `rake gems:install` to install missing gems to the computer
+* `rake gems:unpack` to place a copy of the required gems into `/vendor/gems`
+* `rake gems:unpack:dependencies` to get copies of the required gems and their dependencies into `/vendor/gems`
+* `rake gems:build` to build any missing native extensions
+* `rake gems:refresh_specs` to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
-You can unpack or install a single gem by specifying +GEM=_gem_name_+ on the command line.
+You can unpack or install a single gem by specifying `GEM=_gem_name_` on the command line.
-* Lead Contributor: "Matt Jones":http://github.com/al2o3cr
+* Lead Contributor: [Matt Jones](http://github.com/al2o3cr)
* More information:
-** "What's New in Edge Rails: Gem Dependencies":http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies
-** "Rails 2.1.2 and 2.2RC1: Update Your RubyGems":http://afreshcup.com/2008/10/25/rails-212-and-22rc1-update-your-rubygems/
-** "Detailed discussion on Lighthouse":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1128
+ * [What's New in Edge Rails: Gem Dependencies](http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies)
+ * [Rails 2.1.2 and 2.2RC1: Update Your RubyGems](http://afreshcup.com/2008/10/25/rails-212-and-22rc1-update-your-rubygems/)
+ * [Detailed discussion on Lighthouse](http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1128)
-h4. Other Railties Changes
+### Other Railties Changes
-* If you're a fan of the "Thin":http://code.macournoyer.com/thin/ web server, you'll be happy to know that +script/server+ now supports Thin directly.
-* +script/plugin install &lt;plugin&gt; -r &lt;revision&gt;+ now works with git-based as well as svn-based plugins.
-* +script/console+ now supports a +--debugger+ option
+* If you're a fan of the [Thin](http://code.macournoyer.com/thin/) web server, you'll be happy to know that `script/server` now supports Thin directly.
+* `script/plugin install &lt;plugin&gt; -r &lt;revision&gt;` now works with git-based as well as svn-based plugins.
+* `script/console` now supports a `--debugger` option
* Instructions for setting up a continuous integration server to build Rails itself are included in the Rails source
-* +rake notes:custom ANNOTATION=MYFLAG+ lets you list out custom annotations.
-* Wrapped +Rails.env+ in +StringInquirer+ so you can do +Rails.env.development?+
+* `rake notes:custom ANNOTATION=MYFLAG` lets you list out custom annotations.
+* Wrapped `Rails.env` in `StringInquirer` so you can do `Rails.env.development?`
* To eliminate deprecation warnings and properly handle gem dependencies, Rails now requires rubygems 1.3.1 or higher.
-h3. Deprecated
+Deprecated
+----------
A few pieces of older code are deprecated in this release:
-* +Rails::SecretKeyGenerator+ has been replaced by +ActiveSupport::SecureRandom+
-* +render_component+ is deprecated. There's a "render_components plugin":http://github.com/rails/render_component/tree/master available if you need this functionality.
+* `Rails::SecretKeyGenerator` has been replaced by `ActiveSupport::SecureRandom`
+* `render_component` is deprecated. There's a [render_components plugin](http://github.com/rails/render_component/tree/master) available if you need this functionality.
* Implicit local assignments when rendering partials has been deprecated.
-<ruby>
-def partial_with_implicit_local_assignment
- @customer = Customer.new("Marcel")
- render :partial => "customer"
-end
-</ruby>
+ ```ruby
+ def partial_with_implicit_local_assignment
+ @customer = Customer.new("Marcel")
+ render :partial => "customer"
+ end
+ ```
-Previously the above code made available a local variable called +customer+ inside the partial 'customer'. You should explicitly pass all the variables via :locals hash now.
+ Previously the above code made available a local variable called `customer` inside the partial 'customer'. You should explicitly pass all the variables via :locals hash now.
-* +country_select+ has been removed. See the "deprecation page":http://www.rubyonrails.org/deprecation/list-of-countries for more information and a plugin replacement.
-* +ActiveRecord::Base.allow_concurrency+ no longer has any effect.
-* +ActiveRecord::Errors.default_error_messages+ has been deprecated in favor of +I18n.translate('activerecord.errors.messages')+
-* The +%s+ and +%d+ interpolation syntax for internationalization is deprecated.
-* +String#chars+ has been deprecated in favor of +String#mb_chars+.
-* Durations of fractional months or fractional years are deprecated. Use Ruby's core +Date+ and +Time+ class arithmetic instead.
-* +Request#relative_url_root+ is deprecated. Use +ActionController::Base.relative_url_root+ instead.
+* `country_select` has been removed. See the [deprecation page](http://www.rubyonrails.org/deprecation/list-of-countries) for more information and a plugin replacement.
+* `ActiveRecord::Base.allow_concurrency` no longer has any effect.
+* `ActiveRecord::Errors.default_error_messages` has been deprecated in favor of `I18n.translate('activerecord.errors.messages')`
+* The `%s` and `%d` interpolation syntax for internationalization is deprecated.
+* `String#chars` has been deprecated in favor of `String#mb_chars`.
+* Durations of fractional months or fractional years are deprecated. Use Ruby's core `Date` and `Time` class arithmetic instead.
+* `Request#relative_url_root` is deprecated. Use `ActionController::Base.relative_url_root` instead.
-h3. Credits
+Credits
+-------
-Release notes compiled by "Mike Gunderloy":http://afreshcup.com
+Release notes compiled by [Mike Gunderloy](http://afreshcup.com)
View
535 guides/source/2_3_release_notes.md
@@ -1,14 +1,16 @@
-h2. Ruby on Rails 2.3 Release Notes
+Ruby on Rails 2.3 Release Notes
+===============================
-Rails 2.3 delivers a variety of new and improved features, including pervasive Rack integration, refreshed support for Rails Engines, nested transactions for Active Record, dynamic and default scopes, unified rendering, more efficient routing, application templates, and quiet backtraces. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the "list of commits":http://github.com/rails/rails/commits/master in the main Rails repository on GitHub or review the +CHANGELOG+ files for the individual Rails components.
+Rails 2.3 delivers a variety of new and improved features, including pervasive Rack integration, refreshed support for Rails Engines, nested transactions for Active Record, dynamic and default scopes, unified rendering, more efficient routing, application templates, and quiet backtraces. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the [list of commits](http://github.com/rails/rails/commits/master) in the main Rails repository on GitHub or review the `CHANGELOG` files for the individual Rails components.
-endprologue.
+--------------------------------------------------------------------------------
-h3. Application Architecture
+Application Architecture
+------------------------
-There are two major changes in the architecture of Rails applications: complete integration of the "Rack":http://rack.rubyforge.org/ modular web server interface, and renewed support for Rails Engines.
+There are two major changes in the architecture of Rails applications: complete integration of the [Rack](http://rack.rubyforge.org/) modular web server interface, and renewed support for Rails Engines.
-h4. Rack Integration
+### Rack Integration
Rails has now broken with its CGI past, and uses Rack everywhere. This required and resulted in a tremendous number of internal changes (but if you use CGI, don't worry; Rails now supports CGI through a proxy interface.) Still, this is a major change to Rails internals. After upgrading to 2.3, you should test on your local environment and your production environment. Some things to test:
@@ -19,221 +21,225 @@ Rails has now broken with its CGI past, and uses Rack everywhere. This required
Here's a summary of the rack-related changes:
-* +script/server+ has been switched to use Rack, which means it supports any Rack compatible server. +script/server+ will also pick up a rackup configuration file if one exists. By default, it will look for a +config.ru+ file, but you can override this with the +-c+ switch.
+* `script/server` has been switched to use Rack, which means it supports any Rack compatible server. `script/server` will also pick up a rackup configuration file if one exists. By default, it will look for a `config.ru` file, but you can override this with the `-c` switch.
* The FCGI handler goes through Rack.
-* +ActionController::Dispatcher+ maintains its own default middleware stack. Middlewares can be injected in, reordered, and removed. The stack is compiled into a chain on boot. You can configure the middleware stack in +environment.rb+.
-* The +rake middleware+ task has been added to inspect the middleware stack. This is useful for debugging the order of the middleware stack.
+* `ActionController::Dispatcher` maintains its own default middleware stack. Middlewares can be injected in, reordered, and removed. The stack is compiled into a chain on boot. You can configure the middleware stack in `environment.rb`.
+* The `rake middleware` task has been added to inspect the middleware stack. This is useful for debugging the order of the middleware stack.
* The integration test runner has been modified to execute the entire middleware and application stack. This makes integration tests perfect for testing Rack middleware.
-* +ActionController::CGIHandler+ is a backwards compatible CGI wrapper around Rack. The +CGIHandler+ is meant to take an old CGI object and convert its environment information into a Rack compatible form.
-* +CgiRequest+ and +CgiResponse+ have been removed.
+* `ActionController::CGIHandler` is a backwards compatible CGI wrapper around Rack. The `CGIHandler` is meant to take an old CGI object and convert its environment information into a Rack compatible form.
+* `CgiRequest` and `CgiResponse` have been removed.
* Session stores are now lazy loaded. If you never access the session object during a request, it will never attempt to load the session data (parse the cookie, load the data from memcache, or lookup an Active Record object).
-* You no longer need to use +CGI::Cookie.new+ in your tests for setting a cookie value. Assigning a +String+ value to request.cookies["foo"] now sets the cookie as expected.
-* +CGI::Session::CookieStore+ has been replaced by +ActionController::Session::CookieStore+.
-* +CGI::Session::MemCacheStore+ has been replaced by +ActionController::Session::MemCacheStore+.
-* +CGI::Session::ActiveRecordStore+ has been replaced by +ActiveRecord::SessionStore+.
-* You can still change your session store with +ActionController::Base.session_store = :active_record_store+.
-* Default sessions options are still set with +ActionController::Base.session = { :key => "..." }+. However, the +:session_domain+ option has been renamed to +:domain+.
-* The mutex that normally wraps your entire request has been moved into middleware, +ActionController::Lock+.
-* +ActionController::AbstractRequest+ and +ActionController::Request+ have been unified. The new +ActionController::Request+ inherits from +Rack::Request+. This affects access to +response.headers['type']+ in test requests. Use +response.content_type+ instead.
-* +ActiveRecord::QueryCache+ middleware is automatically inserted onto the middleware stack if +ActiveRecord+ has been loaded. This middleware sets up and flushes the per-request Active Record query cache.
-* The Rails router and controller classes follow the Rack spec. You can call a controller directly with +SomeController.call(env)+. The router stores the routing parameters in +rack.routing_args+.
-* +ActionController::Request+ inherits from +Rack::Request+.
-* Instead of +config.action_controller.session = { :session_key => 'foo', ...+ use +config.action_controller.session = { :key => 'foo', ...+.
-* Using the +ParamsParser+ middleware preprocesses any XML, JSON, or YAML requests so they can be read normally with any +Rack::Request+ object after it.
+* You no longer need to use `CGI::Cookie.new` in your tests for setting a cookie value. Assigning a `String` value to request.cookies["foo"] now sets the cookie as expected.
+* `CGI::Session::CookieStore` has been replaced by `ActionController::Session::CookieStore`.
+* `CGI::Session::MemCacheStore` has been replaced by `ActionController::Session::MemCacheStore`.
+* `CGI::Session::ActiveRecordStore` has been replaced by `ActiveRecord::SessionStore`.
+* You can still change your session store with `ActionController::Base.session_store = :active_record_store`.
+* Default sessions options are still set with `ActionController::Base.session = { :key => "..." }`. However, the `:session_domain` option has been renamed to `:domain`.
+* The mutex that normally wraps your entire request has been moved into middleware, `ActionController::Lock`.
+* `ActionController::AbstractRequest` and `ActionController::Request` have been unified. The new `ActionController::Request` inherits from `Rack::Request`. This affects access to `response.headers['type']` in test requests. Use `response.content_type` instead.
+* `ActiveRecord::QueryCache` middleware is automatically inserted onto the middleware stack if `ActiveRecord` has been loaded. This middleware sets up and flushes the per-request Active Record query cache.
+* The Rails router and controller classes follow the Rack spec. You can call a controller directly with `SomeController.call(env)`. The router stores the routing parameters in `rack.routing_args`.
+* `ActionController::Request` inherits from `Rack::Request`.
+* Instead of `config.action_controller.session = { :session_key => 'foo', ...` use `config.action_controller.session = { :key => 'foo', ...`.
+* Using the `ParamsParser` middleware preprocesses any XML, JSON, or YAML requests so they can be read normally with any `Rack::Request` object after it.
-h4. Renewed Support for Rails Engines
+### Renewed Support for Rails Engines
-After some versions without an upgrade, Rails 2.3 offers some new features for Rails Engines (Rails applications that can be embedded within other applications). First, routing files in engines are automatically loaded and reloaded now, just like your +routes.rb+ file (this also applies to routing files in other plugins). Second, if your plugin has an app folder, then app/[models|controllers|helpers] will automatically be added to the Rails load path. Engines also support adding view paths now, and Action Mailer as well as Action View will use views from engines and other plugins.
+After some versions without an upgrade, Rails 2.3 offers some new features for Rails Engines (Rails applications that can be embedded within other applications). First, routing files in engines are automatically loaded and reloaded now, just like your `routes.rb` file (this also applies to routing files in other plugins). Second, if your plugin has an app folder, then app/[models|controllers|helpers] will automatically be added to the Rails load path. Engines also support adding view paths now, and Action Mailer as well as Action View will use views from engines and other plugins.
-h3. Documentation
+Documentation
+-------------
-The "Ruby on Rails guides":http://guides.rubyonrails.org/ project has published several additional guides for Rails 2.3. In addition, a "separate site":http://edgeguides.rubyonrails.org/ maintains updated copies of the Guides for Edge Rails. Other documentation efforts include a relaunch of the "Rails wiki":http://newwiki.rubyonrails.org/ and early planning for a Rails Book.
+The [Ruby on Rails guides](http://guides.rubyonrails.org/) project has published several additional guides for Rails 2.3. In addition, a [separate site](http://edgeguides.rubyonrails.org/) maintains updated copies of the Guides for Edge Rails. Other documentation efforts include a relaunch of the [Rails wiki](http://newwiki.rubyonrails.org/) and early planning for a Rails Book.
-* More Information: "Rails Documentation Projects":http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.
+* More Information: [Rails Documentation Projects](http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.)
-h3. Ruby 1.9.1 Support
+Ruby 1.9.1 Support
+------------------
Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.
-h3. Active Record
+Active Record
+-------------
Active Record gets quite a number of new features and bug fixes in Rails 2.3. The highlights include nested attributes, nested transactions, dynamic and default scopes, and batch processing.
-h4. Nested Attributes
+### Nested Attributes
Active Record can now update the attributes on nested models directly, provided you tell it to do so:
-<ruby>
+```ruby
class Book < ActiveRecord::Base
has_one :author
has_many :pages
accepts_nested_attributes_for :author, :pages
end
-</ruby>
+```
Turning on nested attributes enables a number of things: automatic (and atomic) saving of a record together with its associated children, child-aware validations, and support for nested forms (discussed later).
-You can also specify requirements for any new records that are added via nested attributes using the +:reject_if+ option:
+You can also specify requirements for any new records that are added via nested attributes using the `:reject_if` option:
-<ruby>
+```ruby
accepts_nested_attributes_for :author,
:reject_if => proc { |attributes| attributes['name'].blank? }
-</ruby>
+```
-* Lead Contributor: "Eloy Duran":http://superalloy.nl/
-* More Information: "Nested Model Forms":http://weblog.rubyonrails.org/2009/1/26/nested-model-forms
+* Lead Contributor: [Eloy Duran](http://superalloy.nl/)
+* More Information: [Nested Model Forms](http://weblog.rubyonrails.org/2009/1/26/nested-model-forms)
-h4. Nested Transactions
+### Nested Transactions
Active Record now supports nested transactions, a much-requested feature. Now you can write code like this:
-<ruby>
+```ruby
User.transaction do
- User.create(:username => 'Admin')
- User.transaction(:requires_new => true) do
- User.create(:username => 'Regular')
- raise ActiveRecord::Rollback
- end
+ User.create(:username => 'Admin')
+ User.transaction(:requires_new => true) do
+ User.create(:username => 'Regular')
+ raise ActiveRecord::Rollback
end
+end
- User.find(:all) # => Returns only Admin
-</ruby>
+User.find(:all) # => Returns only Admin
+```
-Nested transactions let you roll back an inner transaction without affecting the state of the outer transaction. If you want a transaction to be nested, you must explicitly add the +:requires_new+ option; otherwise, a nested transaction simply becomes part of the parent transaction (as it does currently on Rails 2.2). Under the covers, nested transactions are "using savepoints":http://rails.lighthouseapp.com/projects/8994/tickets/383, so they're supported even on databases that don't have true nested transactions. There is also a bit of magic going on to make these transactions play well with transactional fixtures during testing.
+Nested transactions let you roll back an inner transaction without affecting the state of the outer transaction. If you want a transaction to be nested, you must explicitly add the `:requires_new` option; otherwise, a nested transaction simply becomes part of the parent transaction (as it does currently on Rails 2.2). Under the covers, nested transactions are [using savepoints](http://rails.lighthouseapp.com/projects/8994/tickets/383,) so they're supported even on databases that don't have true nested transactions. There is also a bit of magic going on to make these transactions play well with transactional fixtures during testing.
-* Lead Contributors: "Jonathan Viney":http://www.workingwithrails.com/person/4985-jonathan-viney and "Hongli Lai":http://izumi.plan99.net/blog/
+* Lead Contributors: [Jonathan Viney](http://www.workingwithrails.com/person/4985-jonathan-viney) and [Hongli Lai](http://izumi.plan99.net/blog/)
-h4. Dynamic Scopes
+### Dynamic Scopes
-You know about dynamic finders in Rails (which allow you to concoct methods like +find_by_color_and_flavor+ on the fly) and named scopes (which allow you to encapsulate reusable query conditions into friendly names like +currently_active+). Well, now you can have dynamic scope methods. The idea is to put together syntax that allows filtering on the fly _and_ method chaining. For example:
+You know about dynamic finders in Rails (which allow you to concoct methods like `find_by_color_and_flavor` on the fly) and named scopes (which allow you to encapsulate reusable query conditions into friendly names like `currently_active`). Well, now you can have dynamic scope methods. The idea is to put together syntax that allows filtering on the fly _and_ method chaining. For example:
-<ruby>
+```ruby
Order.scoped_by_customer_id(12)
Order.scoped_by_customer_id(12).find(:all,
:conditions => "status = 'open'")
Order.scoped_by_customer_id(12).scoped_by_status("open")
-</ruby>
+```
There's nothing to define to use dynamic scopes: they just work.
-* Lead Contributor: "Yaroslav Markin":http://evilmartians.com/
-* More Information: "What's New in Edge Rails: Dynamic Scope Methods":http://ryandaigle.com/articles/2008/12/29/what-s-new-in-edge-rails-dynamic-scope-methods.
+* Lead Contributor: [Yaroslav Markin](http://evilmartians.com/)
+* More Information: [What's New in Edge Rails: Dynamic Scope Methods](http://ryandaigle.com/articles/2008/12/29/what-s-new-in-edge-rails-dynamic-scope-methods.)
-h4. Default Scopes
+### Default Scopes
-Rails 2.3 will introduce the notion of _default scopes_ similar to named scopes, but applying to all named scopes or find methods within the model. For example, you can write +default_scope :order => 'name ASC'+ and any time you retrieve records from that model they'll come out sorted by name (unless you override the option, of course).
+Rails 2.3 will introduce the notion of _default scopes_ similar to named scopes, but applying to all named scopes or find methods within the model. For example, you can write `default_scope :order => 'name ASC'` and any time you retrieve records from that model they'll come out sorted by name (unless you override the option, of course).
* Lead Contributor: Paweł Kondzior
-* More Information: "What's New in Edge Rails: Default Scoping":http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping
+* More Information: [What's New in Edge Rails: Default Scoping](http://ryandaigle.com/articles/2008/11/18/what-s-new-in-edge-rails-default-scoping)
-h4. Batch Processing
+### Batch Processing
-You can now process large numbers of records from an ActiveRecord model with less pressure on memory by using +find_in_batches+:
+You can now process large numbers of records from an ActiveRecord model with less pressure on memory by using `find_in_batches`:
-<ruby>
+```ruby
Customer.find_in_batches(:conditions => {:active => true}) do |customer_group|
customer_group.each { |customer| customer.update_account_balance! }
end
-</ruby>
+```
-You can pass most of the +find+ options into +find_in_batches+. However, you cannot specify the order that records will be returned in (they will always be returned in ascending order of primary key, which must be an integer), or use the +:limit+ option. Instead, use the +:batch_size+ option, which defaults to 1000, to set the number of records that will be returned in each batch.
+You can pass most of the `find` options into `find_in_batches`. However, you cannot specify the order that records will be returned in (they will always be returned in ascending order of primary key, which must be an integer), or use the `:limit` option. Instead, use the `:batch_size` option, which defaults to 1000, to set the number of records that will be returned in each batch.
-The new +find_each+ method provides a wrapper around +find_in_batches+ that returns individual records, with the find itself being done in batches (of 1000 by default):
+The new `find_each` method provides a wrapper around `find_in_batches` that returns individual records, with the find itself being done in batches (of 1000 by default):
-<ruby>
+```ruby
Customer.find_each do |customer|
customer.update_account_balance!
end
-</ruby>
+```
Note that you should only use this method for batch processing: for small numbers of records (less than 1000), you should just use the regular find methods with your own loop.
-* More Information (at that point the convenience method was called just +each+):
-** "Rails 2.3: Batch Finding":http://afreshcup.com/2009/02/23/rails-23-batch-finding/
-** "What's New in Edge Rails: Batched Find":http://ryandaigle.com/articles/2009/2/23/what-s-new-in-edge-rails-batched-find
+* More Information (at that point the convenience method was called just `each`):
+ * [Rails 2.3: Batch Finding](http://afreshcup.com/2009/02/23/rails-23-batch-finding/)
+ * [What's New in Edge Rails: Batched Find](http://ryandaigle.com/articles/2009/2/23/what-s-new-in-edge-rails-batched-find)
-h4. Multiple Conditions for Callbacks
+### Multiple Conditions for Callbacks
-When using Active Record callbacks, you can now combine +:if+ and +:unless+ options on the same callback, and supply multiple conditions as an array:
+When using Active Record callbacks, you can now combine `:if` and `:unless` options on the same callback, and supply multiple conditions as an array:
-<ruby>
+```ruby
before_save :update_credit_rating, :if => :active,
:unless => [:admin, :cash_only]
-</ruby>
+```
* Lead Contributor: L. Caviola
-h4. Find with having
+### Find with having
-Rails now has a +:having+ option on find (as well as on +has_many+ and +has_and_belongs_to_many+ associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:
+Rails now has a `:having` option on find (as well as on `has_many` and `has_and_belongs_to_many` associations) for filtering records in grouped finds. As those with heavy SQL backgrounds know, this allows filtering based on grouped results:
-<ruby>
+```ruby
developers = Developer.find(:all, :group => "salary",
:having => "sum(salary) > 10000", :select => "salary")
-</ruby>
+```
-* Lead Contributor: "Emilio Tagua":http://github.com/miloops
+* Lead Contributor: [Emilio Tagua](http://github.com/miloops)
-h4. Reconnecting MySQL Connections
+### Reconnecting MySQL Connections
-MySQL supports a reconnect flag in its connections - if set to true, then the client will try reconnecting to the server before giving up in case of a lost connection. You can now set +reconnect = true+ for your MySQL connections in +database.yml+ to get this behavior from a Rails application. The default is +false+, so the behavior of existing applications doesn't change.
+MySQL supports a reconnect flag in its connections - if set to true, then the client will try reconnecting to the server before giving up in case of a lost connection. You can now set `reconnect = true` for your MySQL connections in `database.yml` to get this behavior from a Rails application. The default is `false`, so the behavior of existing applications doesn't change.
-* Lead Contributor: "Dov Murik":http://twitter.com/dubek
+* Lead Contributor: [Dov Murik](http://twitter.com/dubek)
* More information:
-** "Controlling Automatic Reconnection Behavior":http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html
-** "MySQL auto-reconnect revisited":http://groups.google.com/group/rubyonrails-core/browse_thread/thread/49d2a7e9c96cb9f4
-
-h4. Other Active Record Changes
-
-* An extra +AS+ was removed from the generated SQL for +has_and_belongs_to_many+ preloading, making it work better for some databases.
-* +ActiveRecord::Base#new_record?+ now returns +false+ rather than +nil+ when confronted with an existing record.
-* A bug in quoting table names in some +has_many :through+ associations was fixed.
-* You can now specify a particular timestamp for +updated_at+ timestamps: +cust = Customer.create(:name => "ABC Industries", :updated_at => 1.day.ago)+
-* Better error messages on failed +find_by_attribute!+ calls.
-* Active Record's +to_xml+ support gets just a little bit more flexible with the addition of a +:camelize+ option.
-* A bug in canceling callbacks from +before_update+ or +before_create+ was fixed.
+ * [Controlling Automatic Reconnection Behavior](http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html)
+ * [MySQL auto-reconnect revisited](http://groups.google.com/group/rubyonrails-core/browse_thread/thread/49d2a7e9c96cb9f4)
+
+### Other Active Record Changes
+
+* An extra `AS` was removed from the generated SQL for `has_and_belongs_to_many` preloading, making it work better for some databases.
+* `ActiveRecord::Base#new_record?` now returns `false` rather than `nil` when confronted with an existing record.
+* A bug in quoting table names in some `has_many :through` associations was fixed.
+* You can now specify a particular timestamp for `updated_at` timestamps: `cust = Customer.create(:name => "ABC Industries", :updated_at => 1.day.ago)`
+* Better error messages on failed `find_by_attribute!` calls.
+* Active Record's `to_xml` support gets just a little bit more flexible with the addition of a `:camelize` option.
+* A bug in canceling callbacks from `before_update` or `before_create` was fixed.
* Rake tasks for testing databases via JDBC have been added.
-* +validates_length_of+ will use a custom error message with the +:in+ or +:within+ options (if one is supplied).
-* Counts on scoped selects now work properly, so you can do things like +Account.scoped(:select => "DISTINCT credit_limit").count+.
-* +ActiveRecord::Base#invalid?+ now works as the opposite of +ActiveRecord::Base#valid?+.
+* `validates_length_of` will use a custom error message with the `:in` or `:within` options (if one is supplied).
+* Counts on scoped selects now work properly, so you can do things like `Account.scoped(:select => "DISTINCT credit_limit").count`.
+* `ActiveRecord::Base#invalid?` now works as the opposite of `ActiveRecord::Base#valid?`.
-h3. Action Controller
+Action Controller
+-----------------
Action Controller rolls out some significant changes to rendering, as well as improvements in routing and other areas, in this release.
-h4. Unified Rendering
+### Unified Rendering
-+ActionController::Base#render+ is a lot smarter about deciding what to render. Now you can just tell it what to render and expect to get the right results. In older versions of Rails, you often need to supply explicit information to render:
+`ActionController::Base#render` is a lot smarter about deciding what to render. Now you can just tell it what to render and expect to get the right results. In older versions of Rails, you often need to supply explicit information to render:
-<ruby>
+```ruby
render :file => '/tmp/random_file.erb'
render :template => 'other_controller/action'
render :action => 'show'
-</ruby>
+```
Now in Rails 2.3, you can just supply what you want to render:
-<ruby>
+```ruby
render '/tmp/random_file.erb'
render 'other_controller/action'
render 'show'
render :show
-</ruby>
-Rails chooses between file, template, and action depending on whether there is a leading slash, an embedded slash, or no slash at all in what's to be rendered. Note that you can also use a symbol instead of a string when rendering an action. Other rendering styles (+:inline+, +:text+, +:update+, +:nothing+, +:json+, +:xml+, +:js+) still require an explicit option.
+```
+Rails chooses between file, template, and action depending on whether there is a leading slash, an embedded slash, or no slash at all in what's to be rendered. Note that you can also use a symbol instead of a string when rendering an action. Other rendering styles (`:inline`, `:text`, `:update`, `:nothing`, `:json`, `:xml`, `:js`) still require an explicit option.
-h4. Application Controller Renamed
+### Application Controller Renamed
-If you're one of the people who has always been bothered by the special-case naming of +application.rb+, rejoice! It's been reworked to be application_controller.rb in Rails 2.3. In addition, there's a new rake task, +rake rails:update:application_controller+ to do this automatically for you - and it will be run as part of the normal +rake rails:update+ process.
+If you're one of the people who has always been bothered by the special-case naming of `application.rb`, rejoice! It's been reworked to be application_controller.rb in Rails 2.3. In addition, there's a new rake task, `rake rails:update:application_controller` to do this automatically for you - and it will be run as part of the normal `rake rails:update` process.
* More Information:
-** "The Death of Application.rb":http://afreshcup.com/2008/11/17/rails-2x-the-death-of-applicationrb/
-** "What's New in Edge Rails: Application.rb Duality is no More":http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-more
+ * [The Death of Application.rb](http://afreshcup.com/2008/11/17/rails-2x-the-death-of-applicationrb/)
+ * [What's New in Edge Rails: Application.rb Duality is no More](http://ryandaigle.com/articles/2008/11/19/what-s-new-in-edge-rails-application-rb-duality-is-no-more)
-h4. HTTP Digest Authentication Support
+### HTTP Digest Authentication Support
-Rails now has built-in support for HTTP digest authentication. To use it, you call +authenticate_or_request_with_http_digest+ with a block that returns the user’s password (which is then hashed and compared against the transmitted credentials):
+Rails now has built-in support for HTTP digest authentication. To use it, you call `authenticate_or_request_with_http_digest` with a block that returns the user’s password (which is then hashed and compared against the transmitted credentials):
-<ruby>
+```ruby
class PostsController < ApplicationController
Users = {"dhh" => "secret"}
before_filter :authenticate
@@ -250,91 +256,92 @@ class PostsController < ApplicationController
end
end
end
-</ruby>
+```
-* Lead Contributor: "Gregg Kellogg":http://www.kellogg-assoc.com/
-* More Information: "What's New in Edge Rails: HTTP Digest Authentication":http://ryandaigle.com/articles/2009/1/30/what-s-new-in-edge-rails-http-digest-authentication
+* Lead Contributor: [Gregg Kellogg](http://www.kellogg-assoc.com/)
+* More Information: [What's New in Edge Rails: HTTP Digest Authentication](http://ryandaigle.com/articles/2009/1/30/what-s-new-in-edge-rails-http-digest-authentication)
-h4. More Efficient Routing
+### More Efficient Routing
-There are a couple of significant routing changes in Rails 2.3. The +formatted_+ route helpers are gone, in favor just passing in +:format+ as an option. This cuts down the route generation process by 50% for any resource - and can save a substantial amount of memory (up to 100MB on large applications). If your code uses the +formatted_+ helpers, it will still work for the time being - but that behavior is deprecated and your application will be more efficient if you rewrite those routes using the new standard. Another big change is that Rails now supports multiple routing files, not just +routes.rb+. You can use +RouteSet#add_configuration_file+ to bring in more routes at any time - without clearing the currently-loaded routes. While this change is most useful for Engines, you can use it in any application that needs to load routes in batches.
+There are a couple of significant routing changes in Rails 2.3. The `formatted_` route helpers are gone, in favor just passing in `:format` as an option. This cuts down the route generation process by 50% for any resource - and can save a substantial amount of memory (up to 100MB on large applications). If your code uses the `formatted_` helpers, it will still work for the time being - but that behavior is deprecated and your application will be more efficient if you rewrite those routes using the new standard. Another big change is that Rails now supports multiple routing files, not just `routes.rb`. You can use `RouteSet#add_configuration_file` to bring in more routes at any time - without clearing the currently-loaded routes. While this change is most useful for Engines, you can use it in any application that needs to load routes in batches.
-* Lead Contributors: "Aaron Batalion":http://blog.hungrymachine.com/
+* Lead Contributors: [Aaron Batalion](http://blog.hungrymachine.com/)
-h4. Rack-based Lazy-loaded Sessions
+### Rack-based Lazy-loaded Sessions
A big change pushed the underpinnings of Action Controller session storage down to the Rack level. This involved a good deal of work in the code, though it should be completely transparent to your Rails applications (as a bonus, some icky patches around the old CGI session handler got removed). It's still significant, though, for one simple reason: non-Rails Rack applications have access to the same session storage handlers (and therefore the same session) as your Rails applications. In addition, sessions are now lazy-loaded (in line with the loading improvements to the rest of the framework). This means that you no longer need to explicitly disable sessions if you don't want them; just don't refer to them and they won't load.
-h4. MIME Type Handling Changes
+### MIME Type Handling Changes
-There are a couple of changes to the code for handling MIME types in Rails. First, +MIME::Type+ now implements the +=~+ operator, making things much cleaner when you need to check for the presence of a type that has synonyms:
+There are a couple of changes to the code for handling MIME types in Rails. First, `MIME::Type` now implements the `=~` operator, making things much cleaner when you need to check for the presence of a type that has synonyms:
-<ruby>
+```ruby
if content_type && Mime::JS =~ content_type
# do something cool
end
Mime::JS =~ "text/javascript" => true
Mime::JS =~ "application/javascript" => true
-</ruby>
+```
-The other change is that the framework now uses the +Mime::JS+ when checking for JavaScript in various spots, making it handle those alternatives cleanly.
+The other change is that the framework now uses the `Mime::JS` when checking for JavaScript in various spots, making it handle those alternatives cleanly.
-* Lead Contributor: "Seth Fitzsimmons":http://www.workingwithrails.com/person/5510-seth-fitzsimmons
+* Lead Contributor: [Seth Fitzsimmons](http://www.workingwithrails.com/person/5510-seth-fitzsimmons)
-h4. Optimization of +respond_to+
+### Optimization of `respond_to`
-In some of the first fruits of the Rails-Merb team merger, Rails 2.3 includes some optimizations for the +respond_to+ method, which is of course heavily used in many Rails applications to allow your controller to format results differently based on the MIME type of the incoming request. After eliminating a call to +method_missing+ and some profiling and tweaking, we're seeing an 8% improvement in the number of requests per second served with a simple +respond_to+ that switches between three formats. The best part? No change at all required to the code of your application to take advantage of this speedup.
+In some of the first fruits of the Rails-Merb team merger, Rails 2.3 includes some optimizations for the `respond_to` method, which is of course heavily used in many Rails applications to allow your controller to format results differently based on the MIME type of the incoming request. After eliminating a call to `method_missing` and some profiling and tweaking, we're seeing an 8% improvement in the number of requests per second served with a simple `respond_to` that switches between three formats. The best part? No change at all required to the code of your application to take advantage of this speedup.
-h4. Improved Caching Performance
+### Improved Caching Performance
-Rails now keeps a per-request local cache of read from the remote cache stores, cutting down on unnecessary reads and leading to better site performance. While this work was originally limited to +MemCacheStore+, it is available to any remote store than implements the required methods.
+Rails now keeps a per-request local cache of read from the remote cache stores, cutting down on unnecessary reads and leading to better site performance. While this work was originally limited to `MemCacheStore`, it is available to any remote store than implements the required methods.
-* Lead Contributor: "Nahum Wild":http://www.motionstandingstill.com/
+* Lead Contributor: [Nahum Wild](http://www.motionstandingstill.com/)
-h4. Localized Views
+### Localized Views
-Rails can now provide localized views, depending on the locale that you have set. For example, suppose you have a +Posts+ controller with a +show+ action. By default, this will render +app/views/posts/show.html.erb+. But if you set +I18n.locale = :da+, it will render +app/views/posts/show.da.html.erb+. If the localized template isn't present, the undecorated version will be used. Rails also includes +I18n#available_locales+ and +I18n::SimpleBackend#available_locales+, which return an array of the translations that are available in the current Rails project.
+Rails can now provide localized views, depending on the locale that you have set. For example, suppose you have a `Posts` controller with a `show` action. By default, this will render `app/views/posts/show.html.erb`. But if you set `I18n.locale = :da`, it will render `app/views/posts/show.da.html.erb`. If the localized template isn't present, the undecorated version will be used. Rails also includes `I18n#available_locales` and `I18n::SimpleBackend#available_locales`, which return an array of the translations that are available in the current Rails project.
-In addition, you can use the same scheme to localize the rescue files in the +public+ directory: +public/500.da.html+ or +public/404.en.html+ work, for example.
+In addition, you can use the same scheme to localize the rescue files in the `public` directory: `public/500.da.html` or `public/404.en.html` work, for example.
-h4. Partial Scoping for Translations
+### Partial Scoping for Translations
-A change to the translation API makes things easier and less repetitive to write key translations within partials. If you call +translate(".foo")+ from the +people/index.html.erb+ template, you'll actually be calling +I18n.translate("people.index.foo")+ If you don't prepend the key with a period, then the API doesn't scope, just as before.
+A change to the translation API makes things easier and less repetitive to write key translations within partials. If you call `translate(".foo")` from the `people/index.html.erb` template, you'll actually be calling `I18n.translate("people.index.foo")` If you don't prepend the key with a period, then the API doesn't scope, just as before.
-h4. Other Action Controller Changes
+### Other Action Controller Changes
-* ETag handling has been cleaned up a bit: Rails will now skip sending an ETag header when there's no body to the response or when sending files with +send_file+.
-* The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don't generally set things up right. If that's you, you can now set +ActionController::Base.ip_spoofing_check = false+ to disable the check entirely.
-* +ActionController::Dispatcher+ now implements its own middleware stack, which you can see by running +rake middleware+.
+* ETag handling has been cleaned up a bit: Rails will now skip sending an ETag header when there's no body to the response or when sending files with `send_file`.
+* The fact that Rails checks for IP spoofing can be a nuisance for sites that do heavy traffic with cell phones, because their proxies don't generally set things up right. If that's you, you can now set `ActionController::Base.ip_spoofing_check = false` to disable the check entirely.
+* `ActionController::Dispatcher` now implements its own middleware stack, which you can see by running `rake middleware`.
* Cookie sessions now have persistent session identifiers, with API compatibility with the server-side stores.
-* You can now use symbols for the +:type+ option of +send_file+ and +send_data+, like this: +send_file("fabulous.png", :type => :png)+.
-* The +:only+ and +:except+ options for +map.resources+ are no longer inherited by nested resources.
+* You can now use symbols for the `:type` option of `send_file` and `send_data`, like this: `send_file("fabulous.png", :type => :png)`.
+* The `:only` and `:except` options for `map.resources` are no longer inherited by nested resources.
* The bundled memcached client has been updated to version 1.6.4.99.
-* The +expires_in+, +stale?+, and +fresh_when+ methods now accept a +:public+ option to make them work well with proxy caching.
-* The +:requirements+ option now works properly with additional RESTful member routes.
+* The `expires_in`, `stale?`, and `fresh_when` methods now accept a `:public` option to make them work well with proxy caching.
+* The `:requirements` option now works properly with additional RESTful member routes.
* Shallow routes now properly respect namespaces.
-* +polymorphic_url+ does a better job of handling objects with irregular plural names.
+* `polymorphic_url` does a better job of handling objects with irregular plural names.
-h3. Action View
+Action View
+-----------
-Action View in Rails 2.3 picks up nested model forms, improvements to +render+, more flexible prompts for the date select helpers, and a speedup in asset caching, among other things.
+Action View in Rails 2.3 picks up nested model forms, improvements to `render`, more flexible prompts for the date select helpers, and a speedup in asset caching, among other things.
-h4. Nested Object Forms
+### Nested Object Forms
-Provided the parent model accepts nested attributes for the child objects (as discussed in the Active Record section), you can create nested forms using +form_for+ and +field_for+. These forms can be nested arbitrarily deep, allowing you to edit complex object hierarchies on a single view without excessive code. For example, given this model:
+Provided the parent model accepts nested attributes for the child objects (as discussed in the Active Record section), you can create nested forms using `form_for` and `field_for`. These forms can be nested arbitrarily deep, allowing you to edit complex object hierarchies on a single view without excessive code. For example, given this model:
-<ruby>
+```ruby
class Customer < ActiveRecord::Base
has_many :orders
accepts_nested_attributes_for :orders, :allow_destroy => true
end
-</ruby>
+```
You can write this view in Rails 2.3:
-<erb>
+```html+erb
<% form_for @customer do |customer_form| %>
<div>
<%= customer_form.label :name, 'Customer Name:' %>
@@ -363,35 +370,35 @@ You can write this view in Rails 2.3:
<%= customer_form.submit %>
<% end %>
-</erb>
+```
-* Lead Contributor: "Eloy Duran":http://superalloy.nl/
+* Lead Contributor: [Eloy Duran](http://superalloy.nl/)
* More Information:
-** "Nested Model Forms":http://weblog.rubyonrails.org/2009/1/26/nested-model-forms
-** "complex-form-examples":http://github.com/alloy/complex-form-examples
-** "What's New in Edge Rails: Nested Object Forms":http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes
+ * [Nested Model Forms](http://weblog.rubyonrails.org/2009/1/26/nested-model-forms)
+ * [complex-form-examples](http://github.com/alloy/complex-form-examples)
+ * [What's New in Edge Rails: Nested Object Forms](http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes)
-h4. Smart Rendering of Partials
+### Smart Rendering of Partials
The render method has been getting smarter over the years, and it's even smarter now. If you have an object or a collection and an appropriate partial, and the naming matches up, you can now just render the object and things will work. For example, in Rails 2.3, these render calls will work in your view (assuming sensible naming):
-<ruby>
+```ruby
# Equivalent of render :partial => 'articles/_article',
# :object => @article
render @article
# Equivalent of render :partial => 'articles/_article',
# :collection => @articles
render @articles
-</ruby>
+```
-* More Information: "What's New in Edge Rails: render Stops Being High-Maintenance":http://ryandaigle.com/articles/2008/11/20/what-s-new-in-edge-rails-render-stops-being-high-maintenance
+* More Information: [What's New in Edge Rails: render Stops Being High-Maintenance](http://ryandaigle.com/articles/2008/11/20/what-s-new-in-edge-rails-render-stops-being-high-maintenance)
-h4. Prompts for Date Select Helpers
+### Prompts for Date Select Helpers
-In Rails 2.3, you can supply custom prompts for the various date select helpers (+date_select+, +time_select+, and +datetime_select+), the same way you can with collection select helpers. You can supply a prompt string or a hash of individual prompt strings for the various components. You can also just set +:prompt+ to +true+ to use the custom generic prompt:
+In Rails 2.3, you can supply custom prompts for the various date select helpers (`date_select`, `time_select`, and `datetime_select`), the same way you can with collection select helpers. You can supply a prompt string or a hash of individual prompt strings for the various components. You can also just set `:prompt` to `true` to use the custom generic prompt:
-<ruby>
+```ruby
select_datetime(DateTime.now, :prompt => true)
select_datetime(DateTime.now, :prompt => "Choose date and time")
@@ -400,211 +407,215 @@ select_datetime(DateTime.now, :prompt =>
{:day => 'Choose day', :month => 'Choose month',
:year => 'Choose year', :hour => 'Choose hour',
:minute => 'Choose minute'})
-</ruby>
+```
-* Lead Contributor: "Sam Oliver":http://samoliver.com/
+* Lead Contributor: [Sam Oliver](http://samoliver.com/)
-h4. AssetTag Timestamp Caching
+### AssetTag Timestamp Caching
-You're likely familiar with Rails' practice of adding timestamps to static asset paths as a "cache buster." This helps ensure that stale copies of things like images and stylesheets don't get served out of the user's browser cache when you change them on the server. You can now modify this behavior with the +cache_asset_timestamps+ configuration option for Action View. If you enable the cache, then Rails will calculate the timestamp once when it first serves an asset, and save that value. This means fewer (expensive) file system calls to serve static assets - but it also means that you can't modify any of the assets while the server is running and expect the changes to get picked up by clients.
+You're likely familiar with Rails' practice of adding timestamps to static asset paths as a "cache buster." This helps ensure that stale copies of things like images and stylesheets don't get served out of the user's browser cache when you change them on the server. You can now modify this behavior with the `cache_asset_timestamps` configuration option for Action View. If you enable the cache, then Rails will calculate the timestamp once when it first serves an asset, and save that value. This means fewer (expensive) file system calls to serve static assets - but it also means that you can't modify any of the assets while the server is running and expect the changes to get picked up by clients.
-h4. Asset Hosts as Objects
+### Asset Hosts as Objects
Asset hosts get more flexible in edge Rails with the ability to declare an asset host as a specific object that responds to a call. This allows you to implement any complex logic you need in your asset hosting.
-* More Information: "asset-hosting-with-minimum-ssl":http://github.com/dhh/asset-hosting-with-minimum-ssl/tree/master
+* More Information: [asset-hosting-with-minimum-ssl](http://github.com/dhh/asset-hosting-with-minimum-ssl/tree/master)
-h4. grouped_options_for_select Helper Method
+### grouped_options_for_select Helper Method
-Action View already had a bunch of helpers to aid in generating select controls, but now there's one more: +grouped_options_for_select+. This one accepts an array or hash of strings, and converts them into a string of +option+ tags wrapped with +optgroup+ tags. For example:
+Action View already had a bunch of helpers to aid in generating select controls, but now there's one more: `grouped_options_for_select`. This one accepts an array or hash of strings, and converts them into a string of `option` tags wrapped with `optgroup` tags. For example:
-<ruby>
+```ruby
grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]],
"Cowboy Hat", "Choose a product...")
-</ruby>
+```
returns
-<ruby>
+```ruby
<option value="">Choose a product...</option>
<optgroup label="Hats">
<option value="Baseball Cap">Baseball Cap</option>
<option selected="selected" value="Cowboy Hat">Cowboy Hat</option>
</optgroup>
-</ruby>
+```
-h4. Disabled Option Tags for Form Select Helpers
+### Disabled Option Tags for Form Select Helpers
-The form select helpers (such as +select+ and +options_for_select+) now support a +:disabled+ option, which can take a single value or an array of values to be disabled in the resulting tags:
+The form select helpers (such as `select` and `options_for_select`) now support a `:disabled` option, which can take a single value or an array of values to be disabled in the resulting tags:
-<ruby>
-select(:post, :category, Post::CATEGORIES, :disabled => private)
-</ruby>
+```ruby
+select(:post, :category, Post::CATEGORIES, :disabled => 'private')
+```
returns
-<ruby>
+```html
<select name=“post[category]“>
<option>story</option>
<option>joke</option>
<option>poem</option>
<option disabled=“disabled“>private</option>
</select>
-</ruby>
+```
You can also use an anonymous function to determine at runtime which options from collections will be selected and/or disabled:
-<ruby>
+```ruby
options_from_collection_for_select(@product.sizes, :name, :id, :disabled => lambda{|size| size.out_of_stock?})
-</ruby>
+```
-* Lead Contributor: "Tekin Suleyman":http://tekin.co.uk/
-* More Information: "New in rails 2.3 - disabled option tags and lambdas for selecting and disabling options from collections":http://tekin.co.uk/2009/03/new-in-rails-23-disabled-option-tags-and-lambdas-for-selecting-and-disabling-options-from-collections/
+* Lead Contributor: [Tekin Suleyman](http://tekin.co.uk/)
+* More Information: [New in rails 2.3 - disabled option tags and lambdas for selecting and disabling options from collections](http://tekin.co.uk/2009/03/new-in-rails-23-disabled-option-tags-and-lambdas-for-selecting-and-disabling-options-from-collections/)
-h4. A Note About Template Loading
+### A Note About Template Loading
Rails 2.3 includes the ability to enable or disable cached templates for any particular environment. Cached templates give you a speed boost because they don't check for a new template file when they're rendered - but they also mean that you can't replace a template "on the fly" without restarting the server.
-In most cases, you'll want template caching to be turned on in production, which you can do by making a setting in your +production.rb+ file:
+In most cases, you'll want template caching to be turned on in production, which you can do by making a setting in your `production.rb` file:
-<ruby>
+```ruby
config.action_view.cache_template_loading = true
-</ruby>
+```
This line will be generated for you by default in a new Rails 2.3 application. If you've upgraded from an older version of Rails, Rails will default to caching templates in production and test but not in development.
-h4. Other Action View Changes
+### Other Action View Changes
-* Token generation for CSRF protection has been simplified; now Rails uses a simple random string generated by +ActiveSupport::SecureRandom+ rather than mucking around with session IDs.
-* +auto_link+ now properly applies options (such as +:target+ and +:class+) to generated e-mail links.
-* The +autolink+ helper has been refactored to make it a bit less messy and more intuitive.
-* +current_page?+ now works properly even when there are multiple query parameters in the URL.
+* Token generation for CSRF protection has been simplified; now Rails uses a simple random string generated by `ActiveSupport::SecureRandom` rather than mucking around with session IDs.
+* `auto_link` now properly applies options (such as `:target` and `:class`) to generated e-mail links.
+* The `autolink` helper has been refactored to make it a bit less messy and more intuitive.
+* `current_page?` now works properly even when there are multiple query parameters in the URL.
-h3. Active Support
+Active Support
+--------------
-Active Support has a few interesting changes, including the introduction of +Object#try+.
+Active Support has a few interesting changes, including the introduction of `Object#try`.
-h4. Object#try
+### Object#try
-A lot of folks have adopted the notion of using try() to attempt operations on objects. It's especially helpful in views where you can avoid nil-checking by writing code like +&lt;%= @person.try(:name) %&gt;+. Well, now it's baked right into Rails. As implemented in Rails, it raises +NoMethodError+ on private methods and always returns +nil+ if the object is nil.
+A lot of folks have adopted the notion of using try() to attempt operations on objects. It's especially helpful in views where you can avoid nil-checking by writing code like `<%= @person.try(:name) %>`. Well, now it's baked right into Rails. As implemented in Rails, it raises `NoMethodError` on private methods and always returns `nil` if the object is nil.
-* More Information: "try()":http://ozmm.org/posts/try.html.
+* More Information: [try()](http://ozmm.org/posts/try.html.)
-h4. Object#tap Backport
+### Object#tap Backport
-+Object#tap+ is an addition to "Ruby 1.9":http://www.ruby-doc.org/core-1.9/classes/Object.html#M000309 and 1.8.7 that is similar to the +returning+ method that Rails has had for a while: it yields to a block, and then returns the object that was yielded. Rails now includes code to make this available under older versions of Ruby as well.
+`Object#tap` is an addition to [Ruby 1.9](http://www.ruby-doc.org/core-1.9/classes/Object.html#M000309) and 1.8.7 that is similar to the `returning` method that Rails has had for a while: it yields to a block, and then returns the object that was yielded. Rails now includes code to make this available under older versions of Ruby as well.
-h4. Swappable Parsers for XMLmini
+### Swappable Parsers for XMLmini
The support for XML parsing in ActiveSupport has been made more flexible by allowing you to swap in different parsers. By default, it uses the standard REXML implementation, but you can easily specify the faster LibXML or Nokogiri implementations for your own applications, provided you have the appropriate gems installed:
-<ruby>
+```ruby
XmlMini.backend = 'LibXML'
-</ruby>
+```
-* Lead Contributor: "Bart ten Brinke":http://www.movesonrails.com/
-* Lead Contributor: "Aaron Patterson":http://tenderlovemaking.com/
+* Lead Contributor: [Bart ten Brinke](http://www.movesonrails.com/)
+* Lead Contributor: [Aaron Patterson](http://tenderlovemaking.com/)
-h4. Fractional seconds for TimeWithZone
+### Fractional seconds for TimeWithZone
-The +Time+ and +TimeWithZone+ classes include an +xmlschema+ method to return the time in an XML-friendly string. As of Rails 2.3, +TimeWithZone+ supports the same argument for specifying the number of digits in the fractional second part of the returned string that +Time+ does:
+The `Time` and `TimeWithZone` classes include an `xmlschema` method to return the time in an XML-friendly string. As of Rails 2.3, `TimeWithZone` supports the same argument for specifying the number of digits in the fractional second part of the returned string that `Time` does:
-<ruby>
+```ruby
>> Time.zone.now.xmlschema(6)
=> "2009-01-16T13:00:06.13653Z"
-</ruby>
+```
-* Lead Contributor: "Nicholas Dainty":http://www.workingwithrails.com/person/13536-nicholas-dainty
+* Lead Contributor: [Nicholas Dainty](http://www.workingwithrails.com/person/13536-nicholas-dainty)
-h4. JSON Key Quoting
+### JSON Key Quoting
If you look up the spec on the "json.org" site, you'll discover that all keys in a JSON structure must be strings, and they must be quoted with double quotes. Starting with Rails 2.3, we do the right thing here, even with numeric keys.
-h4. Other Active Support Changes
+### Other Active Support Changes
-* You can use +Enumerable#none?+ to check that none of the elements match the supplied block.
-* If you're using Active Support "delegates":http://afreshcup.com/2008/10/19/coming-in-rails-22-delegate-prefixes/, the new +:allow_nil+ option lets you return +nil+ instead of raising an exception when the target object is nil.
-* +ActiveSupport::OrderedHash+: now implements +each_key+ and +each_value+.
-* +ActiveSupport::MessageEncryptor+ provides a simple way to encrypt information for storage in an untrusted location (like cookies).
-* Active Support's +from_xml+ no longer depends on XmlSimple. Instead, Rails now includes its own XmlMini implementation, with just the functionality that it requires. This lets Rails dispense with the bundled copy of XmlSimple that it's been carting around.
+* You can use `Enumerable#none?` to check that none of the elements match the supplied block.
+* If you're using Active Support [delegates](http://afreshcup.com/2008/10/19/coming-in-rails-22-delegate-prefixes/,) the new `:allow_nil` option lets you return `nil` instead of raising an exception when the target object is nil.
+* `ActiveSupport::OrderedHash`: now implements `each_key` and `each_value`.
+* `ActiveSupport::MessageEncryptor` provides a simple way to encrypt information for storage in an untrusted location (like cookies).
+* Active Support's `from_xml` no longer depends on XmlSimple. Instead, Rails now includes its own XmlMini implementation, with just the functionality that it requires. This lets Rails dispense with the bundled copy of XmlSimple that it's been carting around.
* If you memoize a private method, the result will now be private.
-* +String#parameterize+ accepts an optional separator: +"Quick Brown Fox".parameterize('_') => "quick_brown_fox"+.
-* +number_to_phone+ accepts 7-digit phone numbers now.
-* +ActiveSupport::Json.decode+ now handles +\u0000+ style escape sequences.
+* `String#parameterize` accepts an optional separator: `"Quick Brown Fox".parameterize('_') => "quick_brown_fox"`.
+* `number_to_phone` accepts 7-digit phone numbers now.
+* `ActiveSupport::Json.decode` now handles `\u0000` style escape sequences.
-h3. Railties
+Railties
+--------
In addition to the Rack changes covered above, Railties (the core code of Rails itself) sports a number of significant changes, including Rails Metal, application templates, and quiet backtraces.
-h4. Rails Metal
+### Rails Metal
Rails Metal is a new mechanism that provides superfast endpoints inside of your Rails applications. Metal classes bypass routing and Action Controller to give you raw speed (at the cost of all the things in Action Controller, of course). This builds on all of the recent foundation work to make Rails a Rack application with an exposed middleware stack. Metal endpoints can be loaded from your application or from plugins.
* More Information:
-** "Introducing Rails Metal":http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal
-** "Rails Metal: a micro-framework with the power of Rails":http://soylentfoo.jnewland.com/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m
-** "Metal: Super-fast Endpoints within your Rails Apps":http://www.railsinside.com/deployment/180-metal-super-fast-endpoints-within-your-rails-apps.html
-** "What's New in Edge Rails: Rails Metal":http://ryandaigle.com/articles/2008/12/18/what-s-new-in-edge-rails-rails-metal
+ * [Introducing Rails Metal](http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal)
+ * [Rails Metal: a micro-framework with the power of Rails](http://soylentfoo.jnewland.com/articles/2008/12/16/rails-metal-a-micro-framework-with-the-power-of-rails-m)
+ * [Metal: Super-fast Endpoints within your Rails Apps](http://www.railsinside.com/deployment/180-metal-super-fast-endpoints-within-your-rails-apps.html)
+ * [What's New in Edge Rails: Rails Metal](http://ryandaigle.com/articles/2008/12/18/what-s-new-in-edge-rails-rails-metal)
-h4. Application Templates
+### Application Templates
-Rails 2.3 incorporates Jeremy McAnally's "rg":http://github.com/jeremymcanally/rg/tree/master application generator. What this means is that we now have template-based application generation built right into Rails; if you have a set of plugins you include in every application (among many other use cases), you can just set up a template once and use it over and over again when you run the +rails+ command. There's also a rake task to apply a template to an existing application:
+Rails 2.3 incorporates Jeremy McAnally's [rg](http://github.com/jeremymcanally/rg/tree/master) application generator. What this means is that we now have template-based application generation built right into Rails; if you have a set of plugins you include in every application (among many other use cases), you can just set up a template once and use it over and over again when you run the `rails` command. There's also a rake task to apply a template to an existing application:
-<ruby>
+```
rake rails:template LOCATION=~/template.rb
-</ruby>
+```
This will layer the changes from the template on top of whatever code the project already contains.
-* Lead Contributor: "Jeremy McAnally":http://www.jeremymcanally.com/
-* More Info:"Rails templates":http://m.onkey.org/2008/12/4/rails-templates
+* Lead Contributor: [Jeremy McAnally](http://www.jeremymcanally.com/)
+* More Info:[Rails templates](http://m.onkey.org/2008/12/4/rails-templates)
-h4. Quieter Backtraces
+### Quieter Backtraces
-Building on Thoughtbot's "Quiet Backtrace":https://github.com/thoughtbot/quietbacktrace plugin, which allows you to selectively remove lines from +Test::Unit+ backtraces, Rails 2.3 implements +ActiveSupport::BacktraceCleaner+ and +Rails::BacktraceCleaner+ in core. This supports both filters (to perform regex-based substitutions on backtrace lines) and silencers (to remove backtrace lines entirely). Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a +config/backtrace_silencers.rb+ file to hold your own additions. This feature also enables prettier printing from any gem in the backtrace.
+Building on Thoughtbot's [Quiet Backtrace](https://github.com/thoughtbot/quietbacktrace) plugin, which allows you to selectively remove lines from `Test::Unit` backtraces, Rails 2.3 implements `ActiveSupport::BacktraceCleaner` and `Rails::BacktraceCleaner` in core. This supports both filters (to perform regex-based substitutions on backtrace lines) and silencers (to remove backtrace lines entirely). Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a `config/backtrace_silencers.rb` file to hold your own additions. This feature also enables prettier printing from any gem in the backtrace.
-h4. Faster Boot Time in Development Mode with Lazy Loading/Autoload
+### Faster Boot Time in Development Mode with Lazy Loading/Autoload
-Quite a bit of work was done to make sure that bits of Rails (and its dependencies) are only brought into memory when they're actually needed. The core frameworks - Active Support, Active Record, Action Controller, Action Mailer and Action View - are now using +autoload+ to lazy-load their individual classes. This work should help keep the memory footprint down and improve overall Rails performance.
+Quite a bit of work was done to make sure that bits of Rails (and its dependencies) are only brought into memory when they're actually needed. The core frameworks - Active Support, Active Record, Action Controller, Action Mailer and Action View - are now using `autoload` to lazy-load their individual classes. This work should help keep the memory footprint down and improve overall Rails performance.
-You can also specify (by using the new +preload_frameworks+ option) whether the core libraries should be autoloaded at startup. This defaults to +false+ so that Rails autoloads itself piece-by-piece, but there are some circumstances where you still need to bring in everything at once - Passenger and JRuby both want to see all of Rails loaded together.
+You can also specify (by using the new `preload_frameworks` option) whether the core libraries should be autoloaded at startup. This defaults to `false` so that Rails autoloads itself piece-by-piece, but there are some circumstances where you still need to bring in everything at once - Passenger and JRuby both want to see all of Rails loaded together.
-h4. rake gem Task Rewrite
+### rake gem Task Rewrite
The internals of the various <code>rake gem</code> tasks have been substantially revised, to make the system work better for a variety of cases. The gem system now knows the difference between development and runtime dependencies, has a more robust unpacking system, gives better information when querying for the status of gems, and is less prone to "chicken and egg" dependency issues when you're bringing things up from scratch. There are also fixes for using gem commands under JRuby and for dependencies that try to bring in external copies of gems that are already vendored.
-* Lead Contributor: "David Dollar":http://www.workingwithrails.com/person/12240-david-dollar
+* Lead Contributor: [David Dollar](http://www.workingwithrails.com/person/12240-david-dollar)
-h4. Other Railties Changes
+### Other Railties Changes
* The instructions for updating a CI server to build Rails have been updated and expanded.
-* Internal Rails testing has been switched from +Test::Unit::TestCase+ to +ActiveSupport::TestCase+, and the Rails core requires Mocha to test.
-* The default +environment.rb+ file has been decluttered.
+* Internal Rails testing has been switched from `Test::Unit::TestCase` to `ActiveSupport::TestCase`, and the Rails core requires Mocha to test.
+* The default `environment.rb` file has been decluttered.
* The dbconsole script now lets you use an all-numeric password without crashing.
-* +Rails.root+ now returns a +Pathname+ object, which means you can use it directly with the +join+ method to "clean up existing code":http://afreshcup.com/2008/12/05/a-little-rails_root-tidiness/ that uses +File.join+.
-* Various files in /public that deal with CGI and FCGI dispatching are no longer generated in every Rails application by default (you can still get them if you need them by adding +--with-dispatchers+ when you run the +rails+ command, or add them later with +rake rails:update:generate_dispatchers+).
+* `Rails.root` now returns a `Pathname` object, which means you can use it directly with the `join` method to [clean up existing code](http://afreshcup.com/2008/12/05/a-little-rails_root-tidiness/) that uses `File.join`.
+* Various files in /public that deal with CGI and FCGI dispatching are no longer generated in every Rails application by default (you can still get them if you need them by adding `--with-dispatchers` when you run the `rails` command, or add them later with `rake rails:update:generate_dispatchers`).
* Rails Guides have been converted from AsciiDoc to Textile markup.
* Scaffolded views and controllers have been cleaned up a bit.
-* +script/server+ now accepts a <tt>--path</tt> argument to mount a Rails application from a specific path.
+* `script/server` now accepts a <tt>--path</tt> argument to mount a Rails application from a specific path.
* If any configured gems are missing, the gem rake tasks will skip loading much of the environment. This should solve many of the "chicken-and-egg" problems where rake gems:install couldn't run because gems were missing.
* Gems are now unpacked exactly once. This fixes issues with gems (hoe, for instance) which are packed with read-only permissions on the files.
-h3. Deprecated
+Deprecated
+----------
A few pieces of older code are deprecated in this release:
-* If you're one of the (fairly rare) Rails developers who deploys in a fashion that depends on the inspector, reaper, and spawner scripts, you'll need to know that those scripts are no longer included in core Rails. If you need them, you'll be able to pick up copies via the "irs_process_scripts":http://github.com/rails/irs_process_scripts/tree plugin.
-* +render_component+ goes from "deprecated" to "nonexistent" in Rails 2.3. If you still need it, you can install the "render_component plugin":http://github.com/rails/render_component/tree/master.
+* If you're one of the (fairly rare) Rails developers who deploys in a fashion that depends on the inspector, reaper, and spawner scripts, you'll need to know that those scripts are no longer included in core Rails. If you need them, you'll be able to pick up copies via the [irs_process_scripts](http://github.com/rails/irs_process_scripts/tree) plugin.
+* `render_component` goes from "deprecated" to "nonexistent" in Rails 2.3. If you still need it, you can install the [render_component plugin](http://github.com/rails/render_component/tree/master.)
* Support for Rails components has been removed.
-* If you were one of the people who got used to running +script/performance/request+ to look at performance based on integration tests, you need to learn a new trick: that script has been removed from core Rails now. There’s a new request_profiler plugin that you can install to get the exact same functionality back.
-* +ActionController::Base#session_enabled?+ is deprecated because sessions are lazy-loaded now.
-* The +:digest+ and +:secret+ options to +protect_from_forgery+ are deprecated and have no effect.
-* Some integration test helpers have been removed. +response.headers["Status"]+ and +headers["Status"]+ will no longer return anything. Rack does not allow "Status" in its return headers. However you can still use the +status+ and +status_message+ helpers. +response.headers["cookie"]+ and +headers["cookie"]+ will no longer return any CGI cookies. You can inspect +headers["Set-Cookie"]+ to see the raw cookie header or use the +cookies+ helper to get a hash of the cookies sent to the client.
-* +formatted_polymorphic_url+ is deprecated. Use +polymorphic_url+ with +:format+ instead.
-* The +:http_only+ option in +ActionController::Response#set_cookie+ has been renamed to +:httponly+.
-* The +:connector+ and +:skip_last_comma+ options of +to_sentence+ have been replaced by +:words_connnector+, +:two_words_connector+, and +:last_word_connector+ options.
-* Posting a multipart form with an empty +file_field+ control used to submit an empty string to the controller. Now it submits a nil, due to differences between Rack's multipart parser and the old Rails one.
-
-h3. Credits
-
-Release notes compiled by "Mike Gunderloy":http://afreshcup.com. This version of the Rails 2.3 release notes was compiled based on RC2 of Rails 2.3.
+* If you were one of the people who got used to running `script/performance/request` to look at performance based on integration tests, you need to learn a new trick: that script has been removed from core Rails now. There’s a new request_profiler plugin that you can install to get the exact same functionality back.
+* `ActionController::Base#session_enabled?` is deprecated because sessions are lazy-loaded now.
+* The `:digest` and `:secret` options to `protect_from_forgery` are deprecated and have no effect.
+* Some integration test helpers have been removed. `response.headers["Status"]` and `headers["Status"]` will no longer return anything. Rack does not allow "Status" in its return headers. However you can still use the `status` and `status_message` helpers. `response.headers["cookie"]` and `headers["cookie"]` will no longer return any CGI cookies. You can inspect `headers["Set-Cookie"]` to see the raw cookie header or use the `cookies` helper to get a hash of the cookies sent to the client.
+* `formatted_polymorphic_url` is deprecated. Use `polymorphic_url` with `:format` instead.
+* The `:http_only` option in `ActionController::Response#set_cookie` has been renamed to `:httponly`.
+* The `:connector` and `:skip_last_comma` options of `to_sentence` have been replaced by `:words_connnector`, `:two_words_connector`, and `:last_word_connector` options.
+* Posting a multipart form with an empty `file_field` control used to submit an empty string to the controller. Now it submits a nil, due to differences between Rack's multipart parser and the old Rails one.
+
+Credits
+-------
+
+Release notes compiled by [Mike Gunderloy](http://afreshcup.com.) This version of the Rails 2.3 release notes was compiled based on RC2 of Rails 2.3.
View
565 guides/source/3_0_release_notes.md
@@ -1,4 +1,5 @@
-h2. Ruby on Rails 3.0 Release Notes
+Ruby on Rails 3.0 Release Notes
+===============================
Rails 3.0 is ponies and rainbows! It's going to cook you dinner and fold your laundry. You're going to wonder how life was ever possible before it arrived. It's the Best Version of Rails We've Ever Done!
@@ -14,364 +15,374 @@ Even if you don't give a hoot about any of our internal cleanups, Rails 3.0 is g
On top of all that, we've tried our best to deprecate the old APIs with nice warnings. That means that you can move your existing application to Rails 3 without immediately rewriting all your old code to the latest best practices.
-These release notes cover the major upgrades, but don't include every little bug fix and change. Rails 3.0 consists of almost 4,000 commits by more than 250 authors! If you want to see everything, check out the "list of commits":http://github.com/rails/rails/commits/master in the main Rails repository on GitHub.
+These release notes cover the major upgrades, but don't include every little bug fix and change. Rails 3.0 consists of almost 4,000 commits by more than 250 authors! If you want to see everything, check out the [list of commits](http://github.com/rails/rails/commits/master) in the main Rails repository on GitHub.
-endprologue.
+--------------------------------------------------------------------------------
To install Rails 3:
-<shell>
+```bash
# Use sudo if your setup requires it
$ gem install rails
-</shell>
+```
-h3. Upgrading to Rails 3
+Upgrading to Rails 3
+--------------------
If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 2.3.5 and make sure your application still runs as expected before attempting to update to Rails 3. Then take heed of the following changes:
-h4. Rails 3 requires at least Ruby 1.8.7
+### Rails 3 requires at least Ruby 1.8.7
Rails 3.0 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.0 is also compatible with Ruby 1.9.2.
TIP: Note that Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails 3.0. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02 though. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults on Rails 3.0, so if you want to use Rails 3 with 1.9.x jump on 1.9.2 for smooth sailing.
-h4. Rails Application object
+### Rails Application object
-As part of the groundwork for supporting running multiple Rails applications in the same process, Rails 3 introduces the concept of an Application object. An application object holds all the application specific configurations and is very similar in nature to +config/environment.rb+ from the previous versions of Rails.
+As part of the groundwork for supporting running multiple Rails applications in the same process, Rails 3 introduces the concept of an Application object. An application object holds all the application specific configurations and is very similar in nature to `config/environment.rb` from the previous versions of Rails.
-Each Rails application now must have a corresponding application object. The application object is defined in +config/application.rb+. If you're upgrading an existing application to Rails 3, you must add this file and move the appropriate configurations from +config/environment.rb+ to +config/application.rb+.
+Each Rails application now must have a corresponding application object. The application object is defined in `config/application.rb`. If you're upgrading an existing application to Rails 3, you must add this file and move the appropriate configurations from `config/environment.rb` to `config/application.rb`.
-h4. script/* replaced by script/rails
+### script/* replaced by script/rails
-The new <tt>script/rails</tt> replaces all the scripts that used to be in the <tt>script</tt> directory. You do not run <tt>script/rails</tt> directly though, the +rails+ command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is:
+The new `script/rails` replaces all the scripts that used to be in the `script` directory. You do not run `script/rails` directly though, the `rails` command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is:
-<shell>
+```bash
$ rails console # instead of script/console
$ rails g scaffold post title:string # instead of script/generate scaffold post title:string
-</shell>
+```
-Run <tt>rails --help</tt> for a list of all the options.
+Run `rails --help` for a list of all the options.
-h4. Dependencies and config.gem
+### Dependencies and config.gem
-The +config.gem+ method is gone and has been replaced by using +bundler+ and a +Gemfile+, see "Vendoring Gems":#vendoring-gems below.
+The `config.gem` method is gone and has been replaced by using `bundler` and a `Gemfile`, see [Vendoring Gems](#vendoring-gems) below.
-h4. Upgrade Process
+### Upgrade Process
-To help with the upgrade process, a plugin named "Rails Upgrade":http://github.com/rails/rails_upgrade has been created to automate part of it.
+To help with the upgrade process, a plugin named [Rails Upgrade](http://github.com/rails/rails_upgrade) has been created to automate part of it.
-Simply install the plugin, then run +rake rails:upgrade:check+ to check your app for pieces that need to be updated (with links to information on how to update them). It also offers a task to generate a +Gemfile+ based on your current +config.gem+ calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following:
+Simply install the plugin, then run `rake rails:upgrade:check` to check your app for pieces that need to be updated (with links to information on how to update them). It also offers a task to generate a `Gemfile` based on your current `config.gem` calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following:
-<shell>
+```bash
$ ruby script/plugin install git://github.com/rails/rails_upgrade.git
-</shell>
+```
-You can see an example of how that works at "Rails Upgrade is now an Official Plugin":http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin
+You can see an example of how that works at [Rails Upgrade is now an Official Plugin](http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin)
-Aside from Rails Upgrade tool, if you need more help, there are people on IRC and "rubyonrails-talk":http://groups.google.com/group/rubyonrails-talk that are probably doing the same thing, possibly hitting the same issues. Be sure to blog your own experiences when upgrading so others can benefit from your knowledge!
+Aside from Rails Upgrade tool, if you need more help, there are people on IRC and [rubyonrails-talk](http://groups.google.com/group/rubyonrails-talk) that are probably doing the same thing, possibly hitting the same issues. Be sure to blog your own experiences when upgrading so others can benefit from your knowledge!
-More information - "The Path to Rails 3: Approaching the upgrade":http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade
+More information - [The Path to Rails 3: Approaching the upgrade](http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade)
-h3. Creating a Rails 3.0 application
+Creating a Rails 3.0 application
+--------------------------------
-<shell>
+```bash
# You should have the 'rails' rubygem installed
$ rails new myapp
$ cd myapp
-</shell>
+```
-h4. Vendoring Gems
+### Vendoring Gems
-Rails now uses a +Gemfile+ in the application root to determine the gems you require for your application to start. This +Gemfile+ is processed by the "Bundler":http://github.com/carlhuda/bundler, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.
+Rails now uses a `Gemfile` in the application root to determine the gems you require for your application to start. This `Gemfile` is processed by the [Bundler](http://github.com/carlhuda/bundler,) which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.
-More information: - "bundler homepage":http://gembundler.com
+More information: - [bundler homepage](http://gembundler.com)
-h4. Living on the Edge
+### Living on the Edge
-+Bundler+ and +Gemfile+ makes freezing your Rails application easy as pie with the new dedicated <tt>bundle</tt> command, so <tt>rake freeze</tt> is no longer relevant and has been dropped.
+`Bundler` and `Gemfile` makes freezing your Rails application easy as pie with the new dedicated `bundle` command, so `rake freeze` is no longer relevant and has been dropped.
-If you want to bundle straight from the Git repository, you can pass the +--edge+ flag:
+If you want to bundle straight from the Git repository, you can pass the `--edge` flag:
-<shell>
+```bash
$ rails new myapp --edge
-</shell>
+```
-If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the +--dev+ flag:
+If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the `--dev` flag:
-<shell>
+```bash
$ ruby /path/to/rails/bin/rails new myapp --dev
-</shell>
+```
-h3. Rails Architectural Changes
+Rails Architectural Changes
+---------------------------
There are six major changes in the architecture of Rails.
-h4. Railties Restrung
+### Railties Restrung
Railties was updated to provide a consistent plugin API for the entire Rails framework as well as a total rewrite of generators and the Rails bindings, the result is that developers can now hook into any significant stage of the generators and application framework in a consistent, defined manner.
-h4. All Rails core components are decoupled
+### All Rails core components are decoupled
With the merge of Merb and Rails, one of the big jobs was to remove the tight coupling between Rails core components. This has now been achieved, and all Rails core components are now using the same API that you can use for developing plugins. This means any plugin you make, or any core component replacement (like DataMapper or Sequel) can access all the functionality that the Rails core components have access to and extend and enhance at will.
-More information: - "The Great Decoupling":http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
+More information: - [The Great Decoupling](http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/)
-h4. Active Model Abstraction
+### Active Model Abstraction
Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new ORM plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack.
-More information: - "Make Any Ruby Object Feel Like ActiveRecord":http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
+More information: - [Make Any Ruby Object Feel Like ActiveRecord](http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/)
-h4. Controller Abstraction
+### Controller Abstraction
-Another big part of decoupling the core components was creating a base superclass that is separated from the notions of HTTP in order to handle rendering of views etc. This creation of +AbstractController+ allowed +ActionController+ and +ActionMailer+ to be greatly simplified with common code removed from all these libraries and put into Abstract Controller.
+Another big part of decoupling the core components was creating a base superclass that is separated from the notions of HTTP in order to handle rendering of views etc. This creation of `AbstractController` allowed `ActionController` and `ActionMailer` to be greatly simplified with common code removed from all these libraries and put into Abstract Controller.
-More Information: - "Rails Edge Architecture":http://yehudakatz.com/2009/06/11/rails-edge-architecture/
+More Information: - [Rails Edge Architecture](http://yehudakatz.com/2009/06/11/rails-edge-architecture/)
-h4. Arel Integration
+### Arel Integration
-"Arel":http://github.com/brynary/arel (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails. Arel provides an SQL abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record.
+[Arel](http://github.com/brynary/arel) (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails. Arel provides an SQL abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record.
-More information: - "Why I wrote Arel":http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/.
+More information: - [Why I wrote Arel](http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/.)
-h4. Mail Extraction
+### Mail Extraction
-Action Mailer ever since its beginnings has had monkey patches, pre parsers and even delivery and receiver agents, all in addition to having TMail vendored in the source tree. Version 3 changes that with all email message related functionality abstracted out to the "Mail":http://github.com/mikel/mail gem. This again reduces code duplication and helps create definable boundaries between Action Mailer and the email parser.
+Action Mailer ever since its beginnings has had monkey patches, pre parsers and even delivery and receiver agents, all in addition to having TMail vendored in the source tree. Version 3 changes that with all email message related functionality abstracted out to the [Mail](http://github.com/mikel/mail) gem. This again reduces code duplication and helps create definable boundaries between Action Mailer and the email parser.
-More information: - "New Action Mailer API in Rails 3":http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3
+More information: - [New Action Mailer API in Rails 3](http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3)
-h3. Documentation
+Documentation
+-------------
-The documentation in the Rails tree is being updated with all the API changes, additionally, the "Rails Edge Guides":http://edgeguides.rubyonrails.org/ are being updated one by one to reflect the changes in Rails 3.0. The guides at "guides.rubyonrails.org":http://guides.rubyonrails.org/ however will continue to contain only the stable version of Rails (at this point, version 2.3.5, until 3.0 is released).
+The documentation in the Rails tree is being updated with all the API changes, additionally, the [Rails Edge Guides](http://edgeguides.rubyonrails.org/) are being updated one by one to reflect the changes in Rails 3.0. The guides at [guides.rubyonrails.org](http://guides.rubyonrails.org/) however will continue to contain only the stable version of Rails (at this point, version 2.3.5, until 3.0 is released).
-More Information: - "Rails Documentation Projects":http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.
+More Information: - [Rails Documentation Projects](http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.)
-h3. Internationalization
+Internationalization
+--------------------
-A large amount of work has been done with I18n support in Rails 3, including the latest "I18n":http://github.com/svenfuchs/i18n gem supplying many speed improvements.
+A large amount of work has been done with I18n support in Rails 3, including the latest [I18n](http://github.com/svenfuchs/i18n) gem supplying many speed improvements.
-* I18n for any object - I18n behavior can be added to any object by including <tt>ActiveModel::Translation</tt> and <tt>ActiveModel::Validations</tt>. There is also an <tt>errors.messages</tt> fallback for translations.
+* I18n for any object - I18n behavior can be added to any object by including `ActiveModel::Translation` and `ActiveModel::Validations`. There is also an `errors.messages` fallback for translations.
* Attributes can have default translations.
* Form Submit Tags automatically pull the correct status (Create or Update) depending on the object status, and so pull the correct translation.
* Labels with I18n also now work by just passing the attribute name.
-More Information: - "Rails 3 I18n changes":http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/
+More Information: - [Rails 3 I18n changes](http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/)
-h3. Railties
+Railties
+--------
With the decoupling of the main Rails frameworks, Railties got a huge overhaul so as to make linking up frameworks, engines or plugins as painless and extensible as possible:
-* Each application now has its own name space, application is started with <tt>YourAppName.boot</tt> for example, makes interacting with other applications a lot easier.
-* Anything under <tt>Rails.root/app</tt> is now added to the load path, so you can make <tt>app/observers/user_observer.rb</tt> and Rails will load it without any modifications.
-* Rails 3.0 now provides a <tt>Rails.config</tt> object, which provides a central repository of all sorts of Rails wide configuration options.
+* Each application now has its own name space, application is started with `YourAppName.boot` for example, makes interacting with other applications a lot easier.
+* Anything under `Rails.root/app` is now added to the load path, so you can make `app/observers/user_observer.rb` and Rails will load it without any modifications.
+* Rails 3.0 now provides a `Rails.config` object, which provides a central repository of all sorts of Rails wide configuration options.
-Application generation has received extra flags allowing you to skip the installation of test-unit, Active Record, Prototype and Git. Also a new <tt>--dev</tt> flag has been added which sets the application up with the +Gemfile+ pointing to your Rails checkout (which is determined by the path to the +rails+ binary). See <tt>rails --help</tt> for more info.
+ Application generation has received extra flags allowing you to skip the installation of test-unit, Active Record, Prototype and Git. Also a new `--dev` flag has been added which sets the application up with the `Gemfile` pointing to your Rails checkout (which is determined by the path to the `rails` binary). See `rails --help` for more info.
Railties generators got a huge amount of attention in Rails 3.0, basically:
* Generators were completely rewritten and are backwards incompatible.
* Rails templates API and generators API were merged (they are the same as the former).
-* Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling <tt>rails generate foo</tt> will look for <tt>generators/foo_generator</tt>.
+* Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling `rails generate foo` will look for `generators/foo_generator`.
* New generators provide hooks, so any template engine, ORM, test framework can easily hook in.
-* New generators allow you to override the templates by placing a copy at <tt>Rails.root/lib/templates</tt>.
-* <tt>Rails::Generators::TestCase</tt> is also supplied so you can create your own generators and test them.
+* New generators allow you to override the templates by placing a copy at `Rails.root/lib/templates`.
+* `Rails::Generators::TestCase` is also supplied so you can create your own generators and test them.
Also, the views generated by Railties generators had some overhaul:
-* Views now use +div+ tags instead of +p+ tags.
-* Scaffolds generated now make use of <tt>_form</tt> partials, instead of duplicated code in the edit and new views.
-* Scaffold forms now use <tt>f.submit</tt> which returns "Create ModelName" or "Update ModelName" depending on the state of the object passed in.
+* Views now use `div` tags instead of `p` tags.
+* Scaffolds generated now make use of `_form` partials, instead of duplicated code in the edit and new views.
+* Scaffold forms now use `f.submit` which returns "Create ModelName" or "Update ModelName" depending on the state of the object passed in.
Finally a couple of enhancements were added to the rake tasks:
-* <tt>rake db:forward</tt> was added, allowing you to roll forward your migrations individually or in groups.
-* <tt>rake routes CONTROLLER=x</tt> was added allowing you to just view the routes for one controller.
+* `rake db:forward` was added, allowing you to roll forward your migrations individually or in groups.
+* `rake routes CONTROLLER=x` was added allowing you to just view the routes for one controller.
Railties now deprecates:
-* <tt>RAILS_ROOT</tt> in favor of <tt>Rails.root</tt>,
-* <tt>RAILS_ENV</tt> in favor of <tt>Rails.env</tt>, and
-* <tt>RAILS_DEFAULT_LOGGER</tt> in favor of <tt>Rails.logger</tt>.
+* `RAILS_ROOT` in favor of `Rails.root`,
+* `RAILS_ENV` in favor of `Rails.env`, and
+* `RAILS_DEFAULT_LOGGER` in favor of `Rails.logger`.
-<tt>PLUGIN/rails/tasks</tt>, and <tt>PLUGIN/tasks</tt> are no longer loaded all tasks now must be in <tt>PLUGIN/lib/tasks</tt>.
+`PLUGIN/rails/tasks`, and `PLUGIN/tasks` are no longer loaded all tasks now must be in `PLUGIN/lib/tasks`.
More information:
-* "Discovering Rails 3 generators":http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators
-* "Making Generators for Rails 3 with Thor":http://caffeinedd.com/guides/331-making-generators-for-rails-3-with-thor
-* "The Rails Module (in Rails 3)":http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/
-h3. Action Pack
+* [Discovering Rails 3 generators](http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators)
+* [Making Generators for Rails 3 with Thor](http://caffeinedd.com/guides/331-making-generators-for-rails-3-with-thor)
+* [The Rails Module (in Rails 3)](http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/)
+
+Action Pack
+-----------
There have been significant internal and external changes in Action Pack.
-h4. Abstract Controller
+### Abstract Controller
-Abstract Controller pulls out the generic parts of Action Controller into a reusable module that any library can use to render templates, render partials, helpers, translations, logging, any part of the request response cycle. This abstraction allowed <tt>ActionMailer::Base</tt> to now just inherit from +AbstractController+ and just wrap the Rails DSL onto the Mail gem.
+Abstract Controller pulls out the generic parts of Action Controller into a reusable module that any library can use to render templates, render partials, helpers, translations, logging, any part of the request response cycle. This abstraction allowed `ActionMailer::Base` to now just inherit from `AbstractController` and just wrap the Rails DSL onto the Mail gem.
It also provided an opportunity to clean up Action Controller, abstracting out what could to simplify the code.
Note however that Abstract Controller is not a user facing API, you will not run into it in your day to day use of Rails.
-More Information: - "Rails Edge Architecture":http://yehudakatz.com/2009/06/11/rails-edge-architecture/
+More Information: - [Rails Edge Architecture](http://yehudakatz.com/2009/06/11/rails-edge-architecture/)
-h4. Action Controller
+### Action Controller
-* <tt>application_controller.rb</tt> now has <tt>protect_from_forgery</tt> on by default.
-* The <tt>cookie_verifier_secret</tt> has been deprecated and now instead it is assigned through <tt>Rails.application.config.cookie_secret</tt> and moved into its own file: <tt>config/initializers/cookie_verification_secret.rb</tt>.
-* The <tt>session_store</tt> was configured in <tt>ActionController::Base.session</tt>, and that is now moved to <tt>Rails.application.config.session_store</tt>. Defaults are set up in <tt>config/initializers/session_store.rb</tt>.
-* <tt>cookies.secure</tt> allowing you to set encrypted values in cookies with <tt>cookie.secure[:key] => value</tt>.
-* <tt>cookies.permanent</tt> allowing you to set permanent values in the cookie hash <tt>cookie.permanent[:key] => value</tt> that raise exceptions on signed values if verification failures.
-* You can now pass <tt>:notice => 'This is a flash message'</tt> or <tt>:alert => 'Something went wrong'</tt> to the <tt>format</tt> call inside a +respond_to+ block. The <tt>flash[]</tt> hash still works as previously.
-* <tt>respond_with</tt> method has now been added to your controllers simplifying the venerable +format+ blocks.
-* <tt>ActionController::Responder</tt> added allowing you flexibility in how your responses get generated.
+* `application_controller.rb` now has `protect_from_forgery` on by default.
+* The `cookie_verifier_secret` has been deprecated and now instead it is assigned through `Rails.application.config.cookie_secret` and moved into its own file: `config/initializers/cookie_verification_secret.rb`.
+* The `session_store` was configured in `ActionController::Base.session`, and that is now moved to `Rails.application.config.session_store`. Defaults are set up in `config/initializers/session_store.rb`.
+* `cookies.secure` allowing you to set encrypted values in cookies with `cookie.secure[:key] => value`.
+* `cookies.permanent` allowing you to set permanent values in the cookie hash `cookie.permanent[:key] => value` that raise exceptions on signed values if verification failures.
+* You can now pass `:notice => 'This is a flash message'` or `:alert => 'Something went wrong'` to the `format` call inside a `respond_to` block. The `flash[]` hash still works as previously.
+* `respond_with` method has now been added to your controllers simplifying the venerable `format` blocks.
+* `ActionController::Responder` added allowing you flexibility in how your responses get generated.
Deprecations:
-* <tt>filter_parameter_logging</tt> is deprecated in favor of <tt>config.filter_parameters << :password</tt>.
+* `filter_parameter_logging` is deprecated in favor of `config.filter_parameters << :password`.
More Information:
-* "Render Options in Rails 3":http://www.engineyard.com/blog/2010/render-options-in-rails-3/
-* "Three reasons to love ActionController::Responder":http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder
+
+* [Render Options in Rails 3](http://www.engineyard.com/blog/2010/render-options-in-rails-3/)
+* [Three reasons to love ActionController::Responder](http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder)
-h4. Action Dispatch
+### Action Dispatch
Action Dispatch is new in Rails 3.0 and provides a new, cleaner implementation for routing.
-* Big clean up and re-write of the router, the Rails router is now +rack_mount+ with a Rails DSL on top, it is a stand alone piece of software.
+* Big clean up and re-write of the router, the Rails router is now `rack_mount` with a Rails DSL on top, it is a stand alone piece of software.
* Routes defined by each application are now name spaced within your Application module, that is:
-<ruby>
-# Instead of:
+ ```ruby
+ # Instead of:
-ActionController::Routing::Routes.draw do |map|
- map.resources :posts
-end
+ ActionController::Routing::Routes.draw do |map|
+ map.resources :posts
+ end
-# You do:
+ # You do:
-AppName::Application.routes do
- resources :posts
-end
-</ruby>
+ AppName::Application.routes do
+ resources :posts
+ end
+ ```
-* Added +match+ method to the router, you can also pass any Rack application to the matched route.
-* Added +constraints+ method to the router, allowing you to guard routers with defined constraints.
-* Added +scope+ method to the router, allowing you to namespace routes for different languages or different actions, for example:
+* Added `match` method to the router, you can also pass any Rack application to the matched route.
+* Added `constraints` method to the router, allowing you to guard routers with defined constraints.
+* Added `scope` method to the router, allowing you to namespace routes for different languages or different actions, for example:
-<ruby>
-scope 'es' do
- resources :projects, :path_names => { :edit => 'cambiar' }, :path => 'proyecto'
-end
+ ```ruby
+ scope 'es' do
+ resources :projects, :path_names => { :edit => 'cambiar' }, :path => 'proyecto'
+ end
-# Gives you the edit action with /es/proyecto/1/cambiar
-</ruby>
+ # Gives you the edit action with /es/proyecto/1/cambiar
+ ```
-* Added +root+ method to the router as a short cut for <tt>match '/', :to => path</tt>.
-* You can pass optional segments into the match, for example <tt>match "/:controller(/:action(/:id))(.:format)"</tt>, each parenthesized segment is optional.
-* Routes can be expressed via blocks, for example you can call <tt>controller :home { match '/:action' }</tt>.
+* Added `root` method to the router as a short cut for `match '/', :to => path`.
+* You can pass optional segments into the match, for example `match "/:controller(/:action(/:id))(.:format)"`, each parenthesized segment is optional.
+* Routes can be expressed via blocks, for example you can call `controller :home { match '/:action' }`.
-NOTE. The old style <tt>map</tt> commands still work as before with a backwards compatibility layer, however this will be removed in the 3.1 release.
+NOTE. The old style `map` commands still work as before with a backwards compatibility layer, however this will be removed in the 3.1 release.
Deprecations
-* The catch all route for non-REST applications (<tt>/:controller/:action/:id</tt>) is now commented out.
-* Routes :path_prefix no longer exists and :name_prefix now automatically adds "_" at the end of the given value.
+* The catch all route for non-REST applications (`/:controller/:action/:id`) is now commented out.
+* Routes :path\_prefix no longer exists and :name\_prefix now automatically adds "\_" at the end of the given value.
More Information:
-* "The Rails 3 Router: Rack it Up":http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/
-* "Revamped Routes in Rails 3":http://rizwanreza.com/2009/12/20/revamped-routes-in-rails-3
-* "Generic Actions in Rails 3":http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/
+* [The Rails 3 Router: Rack it Up](http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/)
+* [Revamped Routes in Rails 3](http://rizwanreza.com/2009/12/20/revamped-routes-in-rails-3)
+* [Generic Actions in Rails 3](http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/)
-h4. Action View
+### Action View
-h5. Unobtrusive JavaScript
+#### Unobtrusive JavaScript
Major re-write was done in the Action View helpers, implementing Unobtrusive JavaScript (UJS) hooks and removing the old inline AJAX commands. This enables Rails to use any compliant UJS driver to implement the UJS hooks in the helpers.
-What this means is that all previous <tt>remote_&lt;method&gt;</tt> helpers have been removed from Rails core and put into the "Prototype Legacy Helper":http://github.com/rails/prototype_legacy_helper. To get UJS hooks into your HTML, you now pass <tt>:remote => true</tt> instead. For example:
+What this means is that all previous `remote_<method>` helpers have been removed from Rails core and put into the [Prototype Legacy Helper](http://github.com/rails/prototype_legacy_helper.) To get UJS hooks into your HTML, you now pass `:remote => true` instead. For example:
-<ruby>
+```ruby
form_for @post, :remote => true
-</ruby>
+```
Produces:
-<html>
+```html
<form action="http://host.com" id="create-post" method="post" data-remote="true">
-</html>
+```
-h5. Helpers with Blocks
+#### Helpers with Blocks
-Helpers like +form_for+ or +div_for+ that insert content from a block use +&lt;%=+ now:
+Helpers like `form_for` or `div_for` that insert content from a block use `<%=` now:
-<erb>
+```html+erb
<%= form_for @post do |f| %>
...
<% end %>
-</erb>
+```
Your own helpers of that kind are expected to return a string, rather than appending to the output buffer by hand.
-Helpers that do something else, like +cache+ or +content_for+, are not affected by this change, they need +&lt;%+ as before.
+Helpers that do something else, like `cache` or `content_for`, are not affected by this change, they need `&lt;%` as before.
-h5. Other Changes
+#### Other Changes
-* You no longer need to call <tt>h(string)</tt> to escape HTML output, it is on by default in all view templates. If you want the unescaped string, call <tt>raw(string)</tt>.
+* You no longer need to call `h(string)` to escape HTML output, it is on by default in all view templates. If you want the unescaped string, call `raw(string)`.
* Helpers now output HTML 5 by default.
-* Form label helper now pulls values from I18n with a single value, so <tt>f.label :name</tt> will pull the <tt>:name</tt> translation.
+* Form label helper now pulls values from I18n with a single value, so `f.label :name` will pull the `:name` translation.
* I18n select label on should now be :en.helpers.select instead of :en.support.select.
* You no longer need to place a minus sign at the end of a ruby interpolation inside an ERb template to remove the trailing carriage return in the HTML output.
-* Added +grouped_collection_select+ helper to Action View.
-* +content_for?+ has been added allowing you to check for the existence of content in a view before rendering.
-* passing +:value => nil+ to form helpers will set the field's +value+ attribute to nil as opposed to using the default value
-* passing +:id => nil+ to form helpers will cause those fields to be rendered with no +id+ attribute
-* passing +:alt => nil+ to +image_tag+ will cause the +img+ tag to render with no +alt+ attribute
+* Added `grouped_collection_select` helper to Action View.
+* `content_for?` has been added allowing you to check for the existence of content in a view before rendering.
+* passing `:value => nil` to form helpers will set the field's `value` attribute to nil as opposed to using the default value
+* passing `:id => nil` to form helpers will cause those fields to be rendered with no `id` attribute
+* passing `:alt => nil` to `image_tag` will cause the `img` tag to render with no `alt` attribute
-h3. Active Model
+Active Model
+------------
Active Model is new in Rails 3.0. It provides an abstraction layer for any ORM libraries to use to interact with Rails by implementing an Active Model interface.
-h4. ORM Abstraction and Action Pack Interface
+### ORM Abstraction and Action Pack Interface
Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new ORM plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack.
-More Information: - "Make Any Ruby Object Feel Like ActiveRecord":http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
+More Information: - [Make Any Ruby Object Feel Like ActiveRecord](http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/)
-h4. Validations
+### Validations
Validations have been moved from Active Record into Active Model, providing an interface to validations that works across ORM libraries in Rails 3.
-* There is now a <tt>validates :attribute, options_hash</tt> shortcut method that allows you to pass options for all the validates class methods, you can pass more than one option to a validate method.
-* The +validates+ method has the following options:
-** <tt>:acceptance => Boolean</tt>.
-** <tt>:confirmation => Boolean</tt>.
-** <tt>:exclusion => { :in => Enumerable }</tt>.
-** <tt>:inclusion => { :in => Enumerable }</tt>.
-** <tt>:format => { :with => Regexp, :on => :create }</tt>.
-** <tt>:length => { :maximum => Fixnum }</tt>.
-** <tt>:numericality => Boolean</tt>.
-** <tt>:presence => Boolean</tt>.