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.
This commit is contained in:
Senén Rodero Rodríguez
2019-02-13 18:36:55 +01:00
committed by voodoorai2000
parent 036a3d7636
commit ed750f6cce
2 changed files with 12 additions and 12 deletions

View File

@@ -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

View File

@@ -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