It's that time of the week again (every Wednesday for the overly observant, coinciding with the release of the Rails Envy podcast) for some choice updates of what changes have been happening on edge Rails. This week's report covers changes from 4 Feb 2008 to 10 Feb 2008 (the day the Rails Envy podcast was recorded).

More efficent ActiveRecord::Base#attributes

ActiveRecord::Base#attributes returns a hash of all attributes with clones of their objects as values. This unnecessary cloning is expensive, and has now been removed. ActiveRecord::Base#attributes now returns a hash of values of the attributes.

Thanks to Juanjo Bazan, there have been 2 further patches (after the podcast was recorded) related ActiveRecord::Base#attributes that further improves ActiveRecord's performance: removal of cloning from ActiveRecord::Base#attributes_before_typecast, and removing options (:only and :except options, specifically) from ActiveRecord::Base#attributes.

Related changeset:

ActiveResouce::Base#exists? now uses HTTP HEAD instead of a GET

A HTTP HEAD request is really all that is needed to check for existence (200 == exists, 404 == doesn't exist). This has been changed to HEAD from a GET request, which is more efficient since all we retrieve are the HTTP headers and there's no unnecessary instantiation of the ActiveResource object.

Related changeset:

Time zone support for ActiveRecord, and config.time_zone property for specifying a default Time Zone

ActiveRecord models now have time zone-aware attribute readers and writers. Times returned from ActiveRecord attribute readers now have a time_zone attribute themselves, allowing time zone-aware calculations.

You can now configure the default value with config.time_zone in your environment.rb. Setting this will enable time zone-awareness for ActiveRecord models.

Related changeset:

A Template class has been introduced to ActionView

As part of the ActionPack refactoring that's still ongoing, a ActionView::Template class has been introduced to encapsulate all the data relevant to the currently rendered template. This is largely an internal refactoring so Rails users shouldn't be affected.

Related changeset:

Concrete sweeper classes

You can now use an explicit class when declaring a cache_sweeper. E.g.

class ListsController < ApplicationController 
  caches_action :index, :show, :public, :feed 
  cache_sweeper Sweepers::List, :only => [ :edit, :destroy, :share ] 

Related changeset:

As always, let me know of any inaccuracies or any suggestions you may have in the comments - this week's report is a little rushed because I'm a little late in posting it up!