Class: Binda::Board
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Binda::Board
- Extended by:
- FriendlyId
- Includes:
- FieldableAssociations
- Defined in:
- app/models/binda/board.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#create_field_instances ⇒ Object
Create field instances for the current component.
-
#should_generate_new_friendly_id? ⇒ Boolean
Friendly id preference on slug generation.
Methods included from FieldableAssociations
#find_or_create_a_field_by, #generate_fields
Class Method Details
.remove_orphans ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/models/binda/board.rb', line 23 def self.remove_orphans Board .includes(:structure) .where(binda_structures: {id: nil}) .each do |b| b.destroy! puts "Binda::Board with id ##{b.id} successfully destroyed" end end |
Instance Method Details
#create_field_instances ⇒ Object
Create field instances for the current component
34 35 36 37 38 39 40 41 |
# File 'app/models/binda/board.rb', line 34 def create_field_instances instance_field_settings = FieldSetting .includes(field_group: [ :structure ]) .where(binda_structures: { id: self.structure.id }) instance_field_settings.each do |field_setting| field_setting.create_field_instance_for(self) end end |
#should_generate_new_friendly_id? ⇒ Boolean
Friendly id preference on slug generation
Method inherited from friendly id
19 20 21 |
# File 'app/models/binda/board.rb', line 19 def should_generate_new_friendly_id? slug.blank? end |