How to remove duplicates from where in rails -


i have code here

popular = impression.select('impressionable_id, count(impressionable_id) total').group('impressionable_id').order('total desc').limit(9) @events = event.where(id: popular.map(&:impressionable_id)) 

however what's happening @ moment @events returning duplicate names. i'm wondering how return them without returning names match.

update

here's mean,

basically @events working fine, can call @events.eventname , 9 different events in view.

however, if example charity fun day appears twice (has 2 different ids) wouldn't want event name appear twice in this.

@events = event.where(id: popular.map(&:impressionable_id)).uniq 

will give unique event items.

if there events different same names can

@events = event.where(id: popular.map(&:impressionable_id)) @events.uniq{|event| event.name }  

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -