You are lucky, I recently addressed the same problem!
Fortunately for you, the answer is pretty simple. You can use the class method with_translationsto enable translations for a given set of locales.
Here is the code:
def with_translations(*locales)
locales = translated_locales if locales.empty?
includes(:translations).with_locales(locales).with_required_attributes
end
Include it in your method search:
def self.search(search)
if search
with_translations.where('name LIKE ?', "%#{search}%")
else
with_translations
end
end
That should do it.
: locales with_translations, , , , .