2009-01-08 16:33:27 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: assignments
|
|
|
|
#
|
2009-08-01 13:41:22 +02:00
|
|
|
# id :integer(4) not null, primary key
|
|
|
|
# user_id :integer(4) default(0), not null
|
|
|
|
# task_id :integer(4) default(0), not null
|
|
|
|
# accepted :boolean(1)
|
2009-01-08 16:33:27 +01:00
|
|
|
#
|
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
class Assignment < ActiveRecord::Base
|
|
|
|
|
|
|
|
belongs_to :user
|
|
|
|
belongs_to :task
|
|
|
|
|
|
|
|
# after user is assigned mark task as assigned
|
|
|
|
def after_create
|
|
|
|
self.task.update_attribute(:assigned, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
# update assigned-attribute
|
|
|
|
def after_destroy
|
|
|
|
self.task.update_attribute(:assigned, false) if self.task.assignments.empty?
|
|
|
|
end
|
|
|
|
end
|