summaryrefslogtreecommitdiff
path: root/app/models/task.rb
blob: 5f102dd66b83972f1294d2e04d67712384782531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# == Schema Information
#
# Table name: tasks
#
#  id          :integer          not null, primary key
#  user_id     :integer          not null
#  project_id  :integer          not null
#  target_id   :integer          not null
#  target_type :string           not null
#  author_id   :integer
#  action      :integer
#  state       :string           not null
#  created_at  :datetime
#  updated_at  :datetime
#

class Task < ActiveRecord::Base
  belongs_to :author, class_name: "User"
  belongs_to :project
  belongs_to :target, polymorphic: true, touch: true
  belongs_to :user

  validates :action, :project, :target, :user, presence: true

  state_machine :state, initial: :pending do
    state :pending
    state :done
  end
end