Fixed loosing assignments when updating a task.

This commit is contained in:
Benjamin Meichsner 2013-04-08 01:30:31 +02:00 committed by wvengen
parent 93f4239db6
commit 3e9ca336a8

View file

@ -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