Refactor to work with Rails 3.1