Class: Decidim::Category
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Category
- Includes:
- TranslatableResource
- Defined in:
- app/models/decidim/category.rb
Overview
Categories serve as a taxonomy for components to use for while in the context of a participatory process.
Class Method Summary collapse
-
.first_class ⇒ Object
Scope to return only the first-class categories, that is, those that are not subcategories.
Instance Method Summary collapse
Class Method Details
.first_class ⇒ Object
Scope to return only the first-class categories, that is, those that are not subcategories.
Returns an ActiveRecord::Relation.
25 26 27 |
# File 'app/models/decidim/category.rb', line 25 def self.first_class where(parent_id: nil) end |
Instance Method Details
#descendants ⇒ Object
29 30 31 |
# File 'app/models/decidim/category.rb', line 29 def descendants @descendants ||= Category.where(parent_id: id) end |
#translated_name ⇒ Object
33 34 35 |
# File 'app/models/decidim/category.rb', line 33 def translated_name Decidim::CategoryPresenter.new(self).translated_name end |
#unused? ⇒ Boolean
37 38 39 |
# File 'app/models/decidim/category.rb', line 37 def unused? categorizations.empty? end |