From a15a54a4f27382e3e1d1e1b2350523d91aacc0ba Mon Sep 17 00:00:00 2001 From: Gulzar hussain Date: Sat, 7 Dec 2024 15:27:55 +0530 Subject: [PATCH] Fix NoMethodError on nil.distinct in ProductsFinderDecorator - Added a safeguard in the `execute` method of ProductsFinderDecorator to handle cases where no products are found. - Ensures `distinct` is only called on a non-nil object. --- app/finders/spree_multi_vendor/products_finder_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/finders/spree_multi_vendor/products_finder_decorator.rb b/app/finders/spree_multi_vendor/products_finder_decorator.rb index f2e19090..0a1ac9bd 100644 --- a/app/finders/spree_multi_vendor/products_finder_decorator.rb +++ b/app/finders/spree_multi_vendor/products_finder_decorator.rb @@ -9,7 +9,7 @@ def initialize(scope:, params:, current_currency: nil) def execute products = by_vendors(super) - products.distinct + products.try(:distinct) end private