Class: Skyline::Sections::ContentItemSection

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Skyline::SectionItem
Defined in:
app/models/skyline/sections/content_item_section.rb

Class Method Summary collapse

Methods included from Skyline::SectionItem

#to_text

Class Method Details

.register_selectable_model(klass) ⇒ Object



20
21
22
23
24
# File 'app/models/skyline/sections/content_item_section.rb', line 20

def register_selectable_model(klass)
  self.selectable_models ||= []
  self.selectable_models.delete_if{|c| c.to_s == klass.to_s } # Hack to remove stale object
  self.selectable_models << klass
end

.selectable_content_modelsObject



11
12
13
14
15
16
17
18
# File 'app/models/skyline/sections/content_item_section.rb', line 11

def selectable_content_models
  # lazy load all models in /app/models (not recursive) to find all Content models
  Dir.chdir(File.join(Rails.root, "app", "models")) do 
    Dir.glob("*.rb").map{|f| f.sub(".rb","").camelcase.constantize}
  end
  Rails.logger.info "Selectable models for ContentItemSections: " + Skyline::Sections::ContentItemSection.selectable_models.inspect
  selectable_models || []
end