Class: MegaBar::LayablesController

Inherits:
ApplicationController show all
Includes:
MegaBarConcern
Defined in:
app/controllers/mega_bar/layables_controller.rb

Instance Method Summary collapse

Methods included from MegaBarConcern

#add_form_path_to_mega_displays, #collect_filters, #column_sorting, #conditions, #constant_from_controller, #create, #destroy, #edit, #form_path, #is_displayable?, #might_filter?, #might_paginate?, #move, #new, #num_per_page, #process_filters, #redo_setup, #set_vars_for_all, #set_vars_for_displays, #show, #sort_column, #sort_direction, #test_create, #unpack_nested_classes, #update

Methods inherited from ApplicationController

#_params

Instance Method Details

#display_layoutObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/mega_bar/layables_controller.rb', line 16

def display_layout
  m_layout = MegaBar::MasterLayoutsController.new
  m_layout.request = request
  m_layout.response = response
  final_layout_sections = {}
  @layout.template.template_sections.each do |section|
    @layable = @layables.find_by(template_section_id: section.id)
    final_layout_sections[section.code_name] = []
    final_layout_sections[section.code_name][0] = generate_section(section)
 end
  m_layout.instance_variable_set('@mega_layout_sections', final_layout_sections)
  m_layout.instance_variable_set('@mega_layout', @layout)
  # m_layout.instance_variable_set('@layout_helper', true)
  # env['mega_final_layout_sections'] = final_layout_sections #used in master_layouts_controller
  m_layout.render_layout_with_sections
end

#generate_section(template_section) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/mega_bar/layables_controller.rb', line 33

def generate_section(template_section)
  m_layout_section = MegaBar::MasterLayoutSectionsController.new
  m_layout_section.request = request
  m_layout_section.response = response  
  m_layout_section.instance_variable_set('@layable', @layable)
  html = m_layout_section.render_layout_section_admin
  html[0]
  # matches = Gem::Specification.find_all_by_name 'mega_bar'
  # mega = matches.first
  # filename = File.expand_path('app/views/mega_bar/layables/section.html.erb', mega.full_gem_path)
  # template = File.read(filename)
  # final_section = ERB.new(template).result( binding )

  # "I am #{section.code_name}"
end

#indexObject



5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/mega_bar/layables_controller.rb', line 5

def index
  if @layout
    @layables = Layable.where(layout_id: @layout.id)
    # @template = Template.find(@layout.template_id)
    @bob = display_layout
    render
  else 
    super
  end
end