KB answer-to-answer link slug wrong locale bugfix

This commit is contained in:
Mantas 2019-06-05 22:08:27 +03:00
parent 110d60dd30
commit 19c222e7f3
2 changed files with 10 additions and 2 deletions

View file

@ -203,8 +203,8 @@ module KnowledgeBaseHelper
case node['data-target-type']
when 'knowledge-base-answer'
if (translation = KnowledgeBase::Answer::Translation.find_by(id: node['data-target-id']))
path = help_answer_path(translation.answer.category.translation,
translation.answer.translation,
path = help_answer_path(translation.answer.category.translation_preferred(translation.kb_locale),
translation,
locale: translation.kb_locale.system_locale.locale)
node['href'] = custom_path_if_needed path

View file

@ -32,6 +32,14 @@ module HasTranslations
translations.find_by(kb_locale_id: kb_locale_or_id)
end
def translation_preferred(kb_locale_or_id)
translation_to(kb_locale_or_id) || translation_primary || translations.first
end
def translation_primary
translations.joins(:kb_locale).find_by(knowledge_base_locales: { primary: true })
end
class_methods do
def translation_class_name
"#{name}::Translation"