foodsoft/app/models/assignment.rb
benni 8a74e7d77f Removed annoate and hirb Gemfiles.
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
2012-07-27 18:07:42 +02:00

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