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
This should work for you:
Consider Table1 has a column by the name of activity which may have the same value in more than one record. This is how you will extract ONLY the unique entries of activity field within Table1.
#An array of multiple data entries
@table1 = Table1.find(:all)
#extracts **activity** for each entry in the array @table1, and returns only the ones which are unique
@unique_activities = @table1.map{|t| t.activity}.uniq