Key Features for Rails v2.2, Rails v2.3 and the upcoming Rails v3.0

Rails 2.2 new features of interest

  • Ruby 1.9 and JRuby support
  • Transactional Migrations that allow multi-step migrations to be rolled into a transaction.
  • Memoization for caching methods for a request. Allows caching based on passed params as well.
  • *!* Connection Pooling lets Rails distribute database requests across a pool of database connections
  • find_last_by_attribute finder, for example to get the last user who signed up from London:  User.find_last_by_city(‘London’)
  • Layouts for ActionMailer – you can now use layouts in your ActionMailer views.
  • *!* 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.
  1. rake gems:install to install missing gems to the computer
  2. rake gems:unpack to place a copy of the required gems into /vendor/gems
  3. rake gems:unpack:dependencies to get copies of the required gems and their dependencies into /vendor/gems

Rails 2.3 new features of interest

  • ruby 1.9.1 support
  • Engines allow for nested rails applications.
  • Metal allows you to define a area of code that completely bypasses most rails things – does not go through routing, no logging, etc – for areas that need high performance or that get called frequently.
  • Nested transactions within ActiveRecord
  • Dynamic Scopes: Order.scoped_by_customer_id(12).scoped_by_status(“open”)  — no definition needed for dynamic scopes, just works.
  • 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:

for example: before_save :update_credit_rating, :if => :active,  :unless => [:admin, :cash_only]

Rails 3.0 new features of interest (David Heinemeier Hansson KEYNOTE FROM RAILSCONF09)
DHH’s Philosophy of rails 3:

  • Lock up all the unicorns. You can’t please everyone all the time, so don’t focus on the unicorns.
  • No holy cows. Nothing is sacred in rails & everything is up for debate. Don’t look any anything we have & feel like that is the way it has to be.

Major Themes:

  • New routes. Faster, route by subdomain, user agents, etc. Rack to other rack machinery.
  • XSS protection (cross side injection). By default all output in views will be escaped. No more use of <%= h something %>. Assumed by default.
  • Javascript goes Unobtrusive & Agnostic. Much less JS is injected into page & instead unobtrusive JS is used to achieve same effect.
  • More Agnosticism.
  • Action ORM is a slim proxy wrapper for ORM tools that allows for easy swapping of ORM implementation,
  • Generators (script/generator) will for example allow you to specify that rspec is used, so script/generate model will create a rspec test file for model.
  • Refactoring
  • Abstract Controller takes similarities between for example ActionController & ActionMailer and combines them into one code base.
  • Cherry picking from ActiveSupport allowing you to pick parts that are used instead of pulling in the entire library.
  • Increased performance / speed with callbacks.