Controller:
@user_location = Country.joins(:user).order(:name).compact.uniq
View (haml):
- @user_location.each do |user|
%li= user.name
At this point, all duplicate elements of the array are deleted (uniq).
How can I display the number of repetitive elements in the array? For example: if my array has
One Two Two Three Four
then I need to show
One Two (2) Three Four