Class: Pressroom::Category
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pressroom::Category
- Defined in:
- app/models/pressroom/category.rb
Constant Summary
Constants included from Sluggable
Constants included from Scoped
Scoped::NO_SCOPE_ID, Scoped::NO_SCOPE_TYPE
Instance Method Summary collapse
-
#ancestors ⇒ Object
Nearest ancestor first, root last.
- #depth ⇒ Object
Methods included from Scoped
id_for, #scope, #scope=, #scoped?, type_for
Instance Method Details
#ancestors ⇒ Object
Nearest ancestor first, root last.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/pressroom/category.rb', line 22 def ancestors result = [] node = parent while node && !result.include?(node) result << node node = node.parent end result end |
#depth ⇒ Object
34 35 36 |
# File 'app/models/pressroom/category.rb', line 34 def depth ancestors.size end |