From 4911795b21ffad0df0d8adeef7b355a3f5b00823 Mon Sep 17 00:00:00 2001 From: Guido Date: Sun, 22 Aug 2021 18:55:26 -0300 Subject: [PATCH] added optional distinct to filtered_colection to sort nested associations with ransack --- app/controllers/concerns/api/filtered.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/api/filtered.rb b/app/controllers/concerns/api/filtered.rb index 8d69984..c75be49 100644 --- a/app/controllers/concerns/api/filtered.rb +++ b/app/controllers/concerns/api/filtered.rb @@ -1,8 +1,8 @@ module Api::Filtered extend ActiveSupport::Concern - def filtered_collection(collection) - collection.ransack(query_string_filters).result + def filtered_collection(collection, bool = true) + collection.ransack(query_string_filters).result(distinct: bool) end private