Class: Content
- Inherits:
-
Object
- Object
- Content
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/content.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_by_ancestry(ancestry = nil, id) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/models/content.rb', line 36 def self.find_by_ancestry(ancestry = nil, id) return self.find(id) unless ancestry parent = Content.find(ancestry.shift) while(parent_slug = ancestry.shift and parent_slug != id) do parent = parent.child_contents.find(parent_slug) end if parent parent.child_contents.find(id) end |
Instance Method Details
#ancestry ⇒ Object
32 33 34 |
# File 'app/models/content.rb', line 32 def ancestry parent_content ? parent_content.ancestry << id : [id] end |
#child_order ⇒ Object
48 |
# File 'app/models/content.rb', line 48 def child_order; end |
#child_order=(order) ⇒ Object
45 46 47 |
# File 'app/models/content.rb', line 45 def child_order=(order) @child_order = order end |
#to_param ⇒ Object
50 51 52 |
# File 'app/models/content.rb', line 50 def to_param parent_content ? parent_content.to_param + '/' + id : id end |