I am not able to achieve the desired results with the conventional Ruby methods to remove all duplicate objects from the array, user_list, below. Is there a smart way to solve this problem?
users = []
user_list.each do |u|
user = User.find_by_id(u.user_id)
users << user
#users << user unless users.include?(user) # does not work
end
#users = users.uniq # does not work
uniqreally should work. Could you show the steps you took to test it and what your results were? What is the class of the objects in the user's array and how is their==operator defined? Is this Ruby on Rails?Rails 4orRails 3? Oh right, are you using rails at all? If not, what is theUserclass from?