From c668db23324ad0d34fa1ba7eb2230fbc526d70dd Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Tue, 21 Feb 2017 11:44:17 -0500 Subject: [PATCH] correct serialization for unassigned topics --- plugin.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin.rb b/plugin.rb index bbfc262..72d3a41 100644 --- a/plugin.rb +++ b/plugin.rb @@ -292,7 +292,7 @@ SQL attributes :assigned_to_user def assigned_to_user - if user = User.find_by(id: assigned_to_user_id) + if assigned_to_user_id && user = User.find_by(id: assigned_to_user_id) assigned_at = TopicCustomField.where( topic_id: object.topic.id, @@ -310,7 +310,8 @@ SQL def include_assigned_to_user? if SiteSetting.assigns_public || scope.is_staff? - assigned_to_user_id + # subtle but need to catch cases where stuff is not assigned + object.topic.custom_fields.keys.include?("assigned_to_id") end end