What\'s new in Rails 2.1 - Presentation Transcript
What’s new in Rails 2.1?
Keith Pitty
Sydney Rails Meetup
11 June 2008
over 1,400 contributors
more than 1,600 patches
Major features
• Time zones
• Dirty tracking
• Gem dependencies
• Named scope
• UTC-based migrations
• Better caching
New!
Time zones
courtesy of Geoff Busing
$ rake -T time
(in /Users/keithpitty/work/rails2.1demo)
rake time:zones:all # Displays names of all time zones recognized by the...
rake time:zones:local # Displays names of time zones recognized by the Rai...
rake time:zones:us # Displays names of US time zones recognized by the ...
$ rake time:zones:local
* UTC +10:00 *
Brisbane
Canberra
Guam
Hobart
Melbourne
Port Moresby
Sydney
Vladivostok
Use before_filter to set time zone
in ApplicationController
class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
include AuthenticatedSystem
before_filter :set_user_time_zone
private
def set_user_time_zone
Time.zone = current_user.time_zone if logged_in?
end
end
SQL (0.000138) BEGIN
Beer Update (0.000304) UPDATE `beers` SET `updated_at` =
'2008-06-05 11:38:01', `name` = 'Coopers Pale Ale' WHERE
`id` = 1
SQL (0.005019) COMMIT
Warning!
Updates via other than attr= writer
>> b.name_will_change!
=> \"Coopers Pale Ale\"
>> b.name.upcase!
=> \"COOPERS PALE ALE\"
>> b.name_change
=> [\"Coopers Pale Ale\", \"COOPERS PALE ALE\"]
New!
Gem Dependencies
$ rake -T gem
(in /Users/keithpitty/work/rails2.1demo)
rake gems # List the gems that this rails application ...
rake gems:build # Build any native extensions for unpacked gems
rake gems:install # Installs all required gems for this applic...
rake gems:unpack # Unpacks the specified gem into vendor/gems.
rake gems:unpack:dependencies # Unpacks the specified gems and its depende...
rake rails:freeze:gems # Lock this application to the current gems ...
Or subclass ActiveSupport::Cache::Store
and implement read, write, delete and delete_matched methods
New!
A few other tidbits
rake rails:freeze:edge RELEASE=1.2.0
script/plugin install
supports
-e for svn export
and plugins hosted in Git repositories
script/dbconsole
>> \" A string full of white spaces \".squish
=> \"A string full of white spaces\"
Resources
• http://weblog.rubyonrails.com/2008/6/1/rails-2-1-time-zones-
dirty-caching-gem-dependencies-caching-etc
• Ryan Bates’ Railscasts
• Ryan Daigle’s feature introductions
• Ruby on Rails 2.1: What’s New? by Carlos Brando
0 comments
Post a comment