8a74e7d77f
Annotate: Better look in schema.rb, this reference should be always up to date. Hirb: To reactivate hirb, look in railscasts: http://railscasts.com/episodes/48-console-tricks-revised
17 lines
352 B
Ruby
17 lines
352 B
Ruby
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
|
|
|
|
|