Created
March 19, 2013 00:49
-
-
Save jeanfbrito/5192547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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