From 454872edc83d45f61ece47a03ff3d8f0fa9e2748 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 10 Jun 2020 19:52:28 +1000 Subject: [PATCH] Add more checks for edgecases (e.g. when user_field is removed) --- lib/custom_wizard/builder.rb | 4 +++- lib/custom_wizard/mapper.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/custom_wizard/builder.rb b/lib/custom_wizard/builder.rb index c04f11b1..611ed446 100644 --- a/lib/custom_wizard/builder.rb +++ b/lib/custom_wizard/builder.rb @@ -258,7 +258,9 @@ class CustomWizard::Builder } ).perform - if content.present? + if content.present? && + content[:result].present? + if content[:type] == 'association' content[:result] = content[:result].map do |item| { diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index 19b40e6b..50d28815 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -188,7 +188,7 @@ class CustomWizard::Mapper def map_user_field_options(value) if value.include?(User::USER_FIELD_PREFIX) - if field = UserField.find(value.split('_').last) + if field = UserField.find_by(id: value.split('_').last) field.user_field_options.map(&:value) end end