Using Mongoid. Unfortunately, Mongoid does not allow for selecting unique / distinct! Have gotten these results. As you can see, there are 7 results. If you look carefully (at
You can just use the method uniq. Assuming your array is ary, call:
uniq
ary
ary.uniq{|x| x.user_id}
and this will return a set with unique user_ids.
user_id