From 05073d5a28a9f2f1fcd3a954c010e02c1c473c1b Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 30 Jan 2020 12:03:50 +0100 Subject: [PATCH] fix bug for update event recurrent --- app/services/event_service.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/services/event_service.rb b/app/services/event_service.rb index b0554bb06..787d55228 100644 --- a/app/services/event_service.rb +++ b/app/services/event_service.rb @@ -123,7 +123,7 @@ class EventService amount: epca['amount'], _destroy: epca['_destroy'] ) - else + elsif epca['id'].present? event_price = event.event_price_categories.find(epca['id']) epc_attributes.push( price_category_id: epca['price_category_id'], @@ -154,14 +154,20 @@ class EventService ef_attributes.push(efa) end end - unless ef_attributes.empty? - e_params = e_params.merge( - event_files_attributes: ef_attributes - ) + e_params = e_params.merge( + event_files_attributes: ef_attributes + ) + begin + results.push status: !!e.update(e_params.permit!), event: e # rubocop:disable Style/DoubleNegation + rescue => err + results.push status: false, event: e, error: err.try(:record).try(:class).try(:name), message: err.message # rubocop:disable Style/DoubleNegation end - results.push status: !!e.update(e_params.permit!), event: e # rubocop:disable Style/DoubleNegation end - results.push status: !!event.update(event_params), event: event # rubocop:disable Style/DoubleNegation + begin + results.push status: !!event.update(event_params), event: event # rubocop:disable Style/DoubleNegation + rescue => err + results.push status: false, event: event, error: err.try(:record).try(:class).try(:name), message: err.message # rubocop:disable Style/DoubleNegation + end results end end