Skip save callback when migrating data.

This commit is contained in:
Robert Waltemath 2013-06-24 10:36:14 +02:00
parent d081a2c66b
commit 3d1faa9ed3
2 changed files with 4 additions and 5 deletions

View file

@ -20,7 +20,7 @@ class Task < ActiveRecord::Base
validates_length_of :description, maximum: 250
validates :done, exclusion: { in: [true], message: 'erledigte Aufgaben können nicht wöchentlich wiederholt werden' }, if: :periodic?, on: :create
before_save :exclude_from_periodic_task_group
before_save :exclude_from_periodic_task_group, if: :changed?, unless: :new_record?
after_save :update_ordergroup_stats
# Find all tasks, for which the current user should be responsible
@ -110,9 +110,8 @@ class Task < ActiveRecord::Base
end
def exclude_from_periodic_task_group
if changed? and not new_record? and not changed.include? 'periodic_task_group_id'
self.periodic_task_group = nil
end
self.periodic_task_group = nil
true
end
end