ActiveRecord uniq, count and distinct
ActiveRecord has two methods to remove duplicates. Method uniq and option distinct: true in method count. I thought uniq.count and count(distinct: true) were identical. Indeed, uniq.count still counts duplicates, and count(distinct: true) must be used here. In simple words, use uniq to get unique result set, use count(distinct: true) to count unique result.