From 823eb1a9bb508c140a5c88df0f056f409958492c Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Mon, 28 Mar 2011 08:54:55 +0200 Subject: [PATCH] #3178: using a transaction and two save to create an impediment with the appropriate "blocks"-relationship --- app/models/impediment.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/impediment.rb b/app/models/impediment.rb index 0f54ae342b..8ac1fa6deb 100644 --- a/app/models/impediment.rb +++ b/app/models/impediment.rb @@ -15,9 +15,13 @@ class Impediment < Task task.safe_attributes = params task.remaining_hours = 0 if IssueStatus.find(params[:status_id]).is_closed? - task.blocks_ids = params[:blocks] - - if task.save + #an issue relation can not be established between new nodes because their relationship can not be + #evaluated and issue relations between parent and descendant are prohibited. Therefore we need to + #save two times in a transaction + task.transaction do + task.save + task.blocks_ids = params[:blocks] + task.save task.move_after params[:prev] end