Sha256: 7a364c3ef401a7ce65da350a36026ffca63b9c24d3677b84edae02aa266a7b2e

Contents?: true

Size: 895 Bytes

Versions: 27

Compression:

Stored size: 895 Bytes

Contents

module Dorsale
  module Flyboy
    class TaskComment < ActiveRecord::Base
      self.table_name = "dorsale_flyboy_task_comments"

      belongs_to :task
      belongs_to :author, polymorphic: true

      validates :author,      presence: true
      validates :task,        presence: true
      validates :date,        presence: true
      validates :description, presence: true
      validates :progress,    inclusion: {in: 0..100}

      default_scope -> { order("created_at DESC") }

      def initialize(*args)
        super

        self.date     = Time.now if date.nil?

        if progress.nil?
          self.progress = task ? task.progress : 0
        end
      end

      after_create :update_task_progress

      def update_task_progress
        task.update_attributes(
          :progress => progress,
          :done     => progress.equal?(100)
        )
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dorsale-2.2.11 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.10 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.9 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.8 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.6 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.5 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.4 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.3 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.2 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.1 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.2.0 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.15 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.14 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.13 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.12 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.11 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.10 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.9 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.8 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.1.7 app/models/dorsale/flyboy/task_comment.rb