Living on the edge (of Rails) #21

In: Edge Rails|Open Source|Ruby|Ruby on Rails

18 May 2008

It’s another slow week (just 2 changes of note imho) after the release of the 1st Release Candidate (RC1) of Rails 2.1. Follow that link for installation instructions – though if you’re reading this blog post you probably don’t care! (because you’re, you know, “living on the edge”). Cheesiness aside, be sure to report any bugs you may encounter when upgrading to 2.1 RC1 or edge at the Rails bug tracker – it is an RC so any bug reports would be very welcome and useful!

This week’s report covers changes from 12th May 2008 to 18th May 2008 (the day the corresponding Rails Envy podcast was recorded).

caches_action can has conditionals

caches_action now takes an :if option (just like caches_page does). For example:

caches_action :index, :if => Proc.new { |c| !c.request.format.json? }

This little enhancement is courtesy of José Valim.

Related changeset: http://github.com/rails/rails/commit/7708650f73ddb4db300ea2059c60c1d907a4384e

Bugfix: :select option is now scanned in ActiveRecord finders to ensure needed tables are included in generated SQL

Post.find(:all, :include => :author, :select => 'posts.*, authors.id as "author_id"', :limit => 2)

Would generate an SQL statement like this:

SELECT posts.*, authors.id as "author_id" FROM "posts" LIMIT 2

Notice how the authors table is not joined. This oversight is now fixed.

Thanks go to John Devine for this bugfix.

Related changeset: http://github.com/rails/rails/commit/b28b54cab090bed8f099ef375b419a8f92390dd4

As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series. Also, if anyone has any recommendations of (non-ruby-related) things to do in Portland, do let me know!

Comments are closed.