mysql - Rails Active Record group or ignore duplicate results from query -


i have active record query returns list of tags search query. i'm rendering json use in tag search.

the issue query return multiple tags of same kind. there ignore multiples or group multiples?

here's query (sorry it's quite long one):

tag.joins("inner join taggings on taggings.tag_id = tags.id inner join posts on taggings.taggable_id = posts.id inner join buckets on posts.bucket_id = buckets.id inner join memberships on memberships.bucket_id = buckets.id").where(memberships: {user_id: current_user.id, accepted: true}).where("name ?" , "#{params[:query]}%") 

for example, when search 'illustration' 2 posts tagged illustration returned , i'd group one:

enter image description here

thanks!

you should able chain .uniq onto end of query bring unique records. or try .distinct

http://apidock.com/rails/activerecord/querymethods/distinct


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -