Fix bug with ActiveRecord 3