Class: Dscf::Marketplace::Category
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Dscf::Marketplace::Category
- Defined in:
- app/models/dscf/marketplace/category.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
-
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering.
Instance Method Summary collapse
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
21 22 23 |
# File 'app/models/dscf/marketplace/category.rb', line 21 def self.ransackable_associations(_auth_object = nil) %w[parent subcategories products] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering
17 18 19 |
# File 'app/models/dscf/marketplace/category.rb', line 17 def self.ransackable_attributes(_auth_object = nil) %w[id name description code parent_id created_at updated_at] end |
Instance Method Details
#descendants ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/models/dscf/marketplace/category.rb', line 29 def descendants descendants = [] subcategories.each do |subcategory| descendants << subcategory descendants.concat(subcategory.descendants) end descendants end |
#root? ⇒ Boolean
25 26 27 |
# File 'app/models/dscf/marketplace/category.rb', line 25 def root? parent_id.nil? end |