Prevent ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR: current transaction is aborted

, commands ignored until end of transaction block issues.
This commit is contained in:
Martin Edenhofer 2017-08-11 11:10:31 +02:00
parent 5a9138e4be
commit 335b1fad50

View file

@ -8,6 +8,7 @@ class Transaction
ApplicationHandleInfo.current = options[:interface_handle] ApplicationHandleInfo.current = options[:interface_handle]
end end
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin
PushMessages.init PushMessages.init
yield yield
if options[:interface_handle] if options[:interface_handle]
@ -18,6 +19,11 @@ class Transaction
disable: options[:disable], disable: options[:disable],
) )
PushMessages.finish PushMessages.finish
rescue ActiveRecord::StatementInvalid => e
Rails.logger.error e.inspect
Rails.logger.error e.backtrace
raise ActiveRecord::Rollback
end
end end
end end
end end