Skip to content

Instantly share code, notes, and snippets.

@jeanfbrito
Created March 19, 2013 00:49
Show Gist options
  • Save jeanfbrito/5192547 to your computer and use it in GitHub Desktop.
Save jeanfbrito/5192547 to your computer and use it in GitHub Desktop.
class Task < ActiveRecord::Base
extend Enumerize
has_ancestry
attr_accessible :title, :description, :parent_id, :project_id
enumerize :status, in: [:created, :working, :waiting, :paused, :stopped, :finished]
belongs_to :project
belongs_to :priority
has_many :notes
# #self relational code
# has_many :task_subtasks
# has_many :subtasks, :through => :task_subtasks
# has_one :inverse_task_subtasks, :class_name => "TaskSubtask", :foreign_key => "subtask_id"
# has_one :inverse_subtasks, :through => :inverse_task_subtasks, :source => :task
def have_subtasks?
if children.count > 0
return true
end
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment