Class: Decidim::Category
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Category
- Includes:
- FilterableResource, Traceable, TranslatableResource
- Defined in:
- decidim-core/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.
- .log_presenter_class_for(_log) ⇒ Object
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.
27 28 29 |
# File 'decidim-core/app/models/decidim/category.rb', line 27 def self.first_class where(parent_id: nil) end |
.log_presenter_class_for(_log) ⇒ Object
43 44 45 |
# File 'decidim-core/app/models/decidim/category.rb', line 43 def self.log_presenter_class_for(_log) Decidim::AdminLog::CategoryPresenter end |
Instance Method Details
#descendants ⇒ Object
31 32 33 |
# File 'decidim-core/app/models/decidim/category.rb', line 31 def descendants @descendants ||= Category.where(parent_id: id) end |
#translated_name ⇒ Object
35 36 37 |
# File 'decidim-core/app/models/decidim/category.rb', line 35 def translated_name Decidim::CategoryPresenter.new(self).translated_name end |
#unused? ⇒ Boolean
39 40 41 |
# File 'decidim-core/app/models/decidim/category.rb', line 39 def unused? categorizations.empty? end |