Fixed unique count for Rails 4