Sha256: 7f861c2f303b52de59d45e52f1be26cf77a097a40a355aa8f680f2b658ed0bd2

Contents?: true

Size: 896 Bytes

Versions: 29

Compression:

Stored size: 896 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

29 entries across 29 versions & 1 rubygems

Version Path
dorsale-2.7.3 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.7.2 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.7.1 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.7.0 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.8 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.7 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.6 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.5 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.4 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.3 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.2 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.1 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.6.0 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.5.0 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.4.3 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.4.2 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.4.1 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.4.0 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.3.5 app/models/dorsale/flyboy/task_comment.rb
dorsale-2.3.4 app/models/dorsale/flyboy/task_comment.rb