module Flyboy class TaskComment < ActiveRecord::Base belongs_to :task validates :task, presence: true validates :date, presence: true validates :progress, inclusion: {in: 0..100} default_scope -> { order("created_at DESC") } after_create :update_task_progress def update_task_progress task.update_attributes( :progress => progress, :done => progress.equal?(100) ) end end end