Problem with disinct

This commit is contained in:
taitus
2017-08-02 18:41:00 +02:00
parent b412f8a88c
commit 9ef6478e67

View File

@@ -66,12 +66,13 @@ class Proposal < ActiveRecord::Base
proposals_list = self.proposals_not_followed_by_user(user, proposals_list_with_tagged) proposals_list = self.proposals_not_followed_by_user(user, proposals_list_with_tagged)
end end
proposals_list # proposals_list
proposals_list.distinct
end end
def self.proposals_with_tagged(user, proposals_list) def self.proposals_with_tagged(user, proposals_list)
proposals_list.joins(:tags).where('taggings.taggable_type = ?', self.name) proposals_list.joins(:tags).where('taggings.taggable_type = ?', self.name)
.where('tags.name IN (?)', user.interests).group('proposals.id') .where('tags.name IN (?)', user.interests)
end end
def self.proposals_not_followed_by_user(user, proposals_list_with_tagged) def self.proposals_not_followed_by_user(user, proposals_list_with_tagged)