Prevent ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR: current transaction is aborted
, commands ignored until end of transaction block issues.
This commit is contained in:
parent
5a9138e4be
commit
335b1fad50
1 changed files with 15 additions and 9 deletions
|
@ -8,16 +8,22 @@ class Transaction
|
||||||
ApplicationHandleInfo.current = options[:interface_handle]
|
ApplicationHandleInfo.current = options[:interface_handle]
|
||||||
end
|
end
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
PushMessages.init
|
begin
|
||||||
yield
|
PushMessages.init
|
||||||
if options[:interface_handle]
|
yield
|
||||||
ApplicationHandleInfo.current = original_interface_handle
|
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
|
end
|
||||||
Observer::Transaction.commit(
|
|
||||||
disable_notification: options[:disable_notification],
|
|
||||||
disable: options[:disable],
|
|
||||||
)
|
|
||||||
PushMessages.finish
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue