From c496d2c76341773fd481fde49f4e07457c66a4b4 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 30 Aug 2023 11:48:16 +0200 Subject: [PATCH] Fix transaction rollback [SCI-9088] --- app/controllers/assets_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index ce1ef3409..4633cc2a3 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -83,15 +83,16 @@ class AssetsController < ApplicationController target = @assoc.protocol.steps.find_by(id: params[:target_id]) object_to_update = @asset.step_asset object_to_update.update!(step: target) - render json: { status: :ok } + render json: {} elsif @assoc.is_a?(Result) target = @assoc.my_module.results.find_by(id: params[:target_id]) object_to_update = @asset.result_asset object_to_update.update!(result: target) - render json: { status: :ok } + render json: {} end rescue ActiveRecord::RecordInvalid render json: object_to_update.errors, status: :unprocessable_entity + raise ActiveRecord::Rollback end end