From 238eba4a50da3fd0ad7a12e7c7629ec24daf836a Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 18 Jun 2020 14:20:18 -0500 Subject: [PATCH] full_contact action only returns FullContact details if the gem is installed --- app/controllers/nonprofits/supporters_controller.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/nonprofits/supporters_controller.rb b/app/controllers/nonprofits/supporters_controller.rb index 29b7d31f..25d85651 100644 --- a/app/controllers/nonprofits/supporters_controller.rb +++ b/app/controllers/nonprofits/supporters_controller.rb @@ -58,10 +58,14 @@ module Nonprofits end def full_contact - fc = FullContactInfo.where("supporter_id=#{params[:id]}").first - if fc - render json: { full_contact: QueryFullContactInfos.fetch_associated_tables(fc.id) } - else + begin + s = Supporter.find params[:id] + if s.method_defined? :full_contact_infos && (fc = s.full_contact_infos.first) + render json: { full_contact: QueryFullContactInfos.fetch_associated_tables(fc.id) } + else + render json: { full_contact: nil } + end + rescue render json: { full_contact: nil } end end