diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 25b94fa55..7d121c3bf 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -8,16 +8,22 @@ class Transaction ApplicationHandleInfo.current = options[:interface_handle] end ActiveRecord::Base.transaction do - PushMessages.init - yield - if options[:interface_handle] - ApplicationHandleInfo.current = original_interface_handle + begin + PushMessages.init + yield + if options[:interface_handle] + ApplicationHandleInfo.current = original_interface_handle + end + Observer::Transaction.commit( + disable_notification: options[:disable_notification], + disable: options[:disable], + ) + PushMessages.finish + rescue ActiveRecord::StatementInvalid => e + Rails.logger.error e.inspect + Rails.logger.error e.backtrace + raise ActiveRecord::Rollback end - Observer::Transaction.commit( - disable_notification: options[:disable_notification], - disable: options[:disable], - ) - PushMessages.finish end end end