diff --git a/app/models/metadata_locales.rb b/app/models/metadata_locales.rb index 37b50286..85419da8 100644 --- a/app/models/metadata_locales.rb +++ b/app/models/metadata_locales.rb @@ -33,17 +33,15 @@ class MetadataLocales < MetadataHasAndBelongsToMany # # @return [Array] def other_locales - site.locales.reject do |locale| - locale == post.lang.value.to_sym + @other_locales ||= site.locales.reject do |other_locale| + other_locale.to_s == locale end end # Obtiene todos los posts de los otros locales con el mismo layout # - # @return [PostRelation] + # @return [IndexedPost::ActiveRecord_AssociationRelation] def posts - other_locales.map do |locale| - site.posts(lang: locale).where(layout: post.layout.value) - end.reduce(&:concat) || PostRelation.new(site: site, lang: 'any') + site.indexed_posts(locale: other_locales).where(layout: post.layout.value).where.not(post_id: post.uuid.value) end end