2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2019-06-04 03:40:48 +00:00
|
|
|
|
|
|
|
class KnowledgeBase::Public::AnswersController < KnowledgeBase::Public::BaseController
|
|
|
|
|
|
|
|
def show
|
|
|
|
@category = find_category(params[:category])
|
|
|
|
@object = find_answer(@category&.answers, params[:answer])
|
|
|
|
@object_locales = find_locales(@object)
|
|
|
|
|
|
|
|
render_alternative if @object.blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def render_alternative
|
2021-07-23 13:07:16 +00:00
|
|
|
@alternative = policy_scope(@knowledge_base.answers)
|
2019-06-04 03:40:48 +00:00
|
|
|
.eager_load(translations: :kb_locale)
|
|
|
|
.find_by(id: params[:answer])
|
|
|
|
|
|
|
|
raise ActiveRecord::RecordNotFound if !@alternative&.translations&.any?
|
|
|
|
|
|
|
|
@object_locales = @alternative.translations.map(&:kb_locale).map(&:system_locale)
|
|
|
|
|
|
|
|
render 'knowledge_base/public/show_alternatives', locals: { name: 'Answer' }
|
|
|
|
end
|
|
|
|
end
|