From 95b0758647f56eb50690af7bb9dd61ee63a7cb46 Mon Sep 17 00:00:00 2001 From: angusmcleod Date: Tue, 5 Oct 2021 10:07:21 +0800 Subject: [PATCH] COMPATIBILITY: Add backwards compatibility for category serialization --- serializers/custom_wizard/wizard_serializer.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/serializers/custom_wizard/wizard_serializer.rb b/serializers/custom_wizard/wizard_serializer.rb index f23ff7e1..708b962d 100644 --- a/serializers/custom_wizard/wizard_serializer.rb +++ b/serializers/custom_wizard/wizard_serializer.rb @@ -64,6 +64,12 @@ class CustomWizard::WizardSerializer < CustomWizard::BasicWizardSerializer end def categories - object.categories.map { |c| c.to_h } + object.categories.map do |category| + if category.respond_to?(:to_h) + category.to_h + else + ::BasicCategorySerializer.new(category).as_json + end + end end end