Reputation: 7280
I am working on integrating Solr search with a RoR app. The solr returns docs which have a field productTaxonomyName
.
In the controller corresponding to search I retrieve docs from solr and push them into a @products
array. I want to get the set of unique values of the productTaxonomyName
field in a variable within the controller. How can I do that.
Will this work:
@taxons = @products.map {|p| p.productTaxonomyName }
Thanks
Upvotes: 0
Views: 45
Reputation: 2349
@taxons = @products.map(&:productTaxonomyName).compact.uniq
Btw, why dont you get them right from Solr.
Upvotes: 1