From 3057b70bfe7e25e4dee80cae10c408238f040a02 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Mon, 7 Dec 2015 15:45:31 -0300 Subject: [PATCH] return distinct elements in by_enterprise scope --- app/models/product_category.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/product_category.rb b/app/models/product_category.rb index 4039b88..901df33 100644 --- a/app/models/product_category.rb +++ b/app/models/product_category.rb @@ -7,7 +7,7 @@ class ProductCategory < Category scope :unique, :select => 'DISTINCT ON (path) categories.*' scope :by_enterprise, -> enterprise { - joins(:products). + distinct.joins(:products). where('products.profile_id = ?', enterprise.id) } scope :by_environment, -> environment { -- libgit2 0.21.2