Sha256: f3f2d10445a85d9c58755eb3a3943ed14e02b3fab3f57e6ce114e56f1165d06d

Contents?: true

Size: 448 Bytes

Versions: 5

Compression:

Stored size: 448 Bytes

Contents

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flyboy-0.0.5 app/models/flyboy/task_comment.rb
flyboy-0.0.4 app/models/flyboy/task_comment.rb
flyboy-0.0.3 app/models/flyboy/task_comment.rb
flyboy-0.0.2 app/models/flyboy/task_comment.rb
flyboy-0.0.1 app/models/flyboy/task_comment.rb