From 03ea8e194ed0559402c1ed4fbc73e55775c36f18 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Mon, 8 Apr 2013 01:30:31 +0200 Subject: [PATCH] Fixed loosing assignments when updating a task. --- app/models/task.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/task.rb b/app/models/task.rb index bef3a44e..64c5ff20 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -66,13 +66,10 @@ class Task < ActiveRecord::Base # and makes the users responsible for the task # TODO: check for maximal number of users def user_list=(ids) - list = ids.split(",") + list = ids.split(",").map(&:to_i) new_users = (list - users.collect(&:id)).uniq old_users = users.reject { |user| list.include?(user.id) } - logger.debug "[debug] New users: #{new_users}" - logger.debug "Old users: #{old_users}" - self.class.transaction do # delete old assignments if old_users.any? @@ -84,7 +81,7 @@ class Task < ActiveRecord::Base if user.blank? errors.add(:user_list) else - if id == current_user_id + if id == current_user_id.to_i # current_user will accept, when he puts himself to the list of users self.assignments.build :user => user, :accepted => true else