From ed750f6cce613d9be2718e115fc2330e2f9af699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 13 Feb 2019 18:36:55 +0100 Subject: [PATCH] Move private method to a more reusable location This method will be used by any translatable model that uses pg_search feature so it's better to have it within globalizable model concern so all translatable models can use it. --- app/models/concerns/globalizable.rb | 12 ++++++++++++ app/models/debate.rb | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/concerns/globalizable.rb b/app/models/concerns/globalizable.rb index df054caaf..6501041d0 100644 --- a/app/models/concerns/globalizable.rb +++ b/app/models/concerns/globalizable.rb @@ -20,6 +20,18 @@ module Globalizable if self.paranoid? && translation_class.attribute_names.include?("hidden_at") translation_class.send :acts_as_paranoid, column: :hidden_at end + + private + + def searchable_globalized_values + values = {} + translations.each do |translation| + Globalize.with_locale(translation.locale) do + values.merge! searchable_translations_definitions + end + end + values + end end class_methods do diff --git a/app/models/debate.rb b/app/models/debate.rb index eacd4e55b..b3a23200a 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -165,16 +165,4 @@ class Debate < ApplicationRecord orders << "recommendations" if Setting["feature.user.recommendations_on_debates"] && user&.recommended_debates return orders end - - private - - def searchable_globalized_values - values = {} - translations.each do |translation| - Globalize.with_locale(translation.locale) do - values.merge! searchable_translations_definitions - end - end - values - end end