Upgrade ActiveRecord queries for Rails 3.1 preparation