Sha256: 36bd5ae6aade11ab605d8083332cd600e6a187be331cff611098ad1e484a8b21

Contents?: true

Size: 740 Bytes

Versions: 13

Compression:

Stored size: 740 Bytes

Contents

class Dorsale::Flyboy::TaskComment < ::Dorsale::ApplicationRecord
  self.table_name = "dorsale_flyboy_task_comments"

  belongs_to :task
  belongs_to :author, class_name: User

  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(date: :desc) }

  def assign_default_values
    assign_default :date,     Time.zone.now
    assign_default :progress, (task ? task.progress : 0)
  end

  after_create :update_task_progress

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dorsale-3.10.3 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.10.2 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.10.1 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.10.0 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.8 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.7 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.6 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.5 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.4 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.3 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.2 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.1 app/models/dorsale/flyboy/task_comment.rb
dorsale-3.9.0 app/models/dorsale/flyboy/task_comment.rb