Update query to Rails 3/4 syntax