Module: Optimacms::Mycontroller

Defined in:
lib/optimacms/mycontroller.rb

Instance Method Summary collapse

Instance Method Details

#default_render(*args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/optimacms/mycontroller.rb', line 14

def default_render(*args)
  if self.controller_name!='pages' && !@optimacms_tpl.nil? && @is_optimacms
    render @optimacms_tpl, :layout=>@optimacms_layout and return
    #(render :text => "hello", :layout => @optimacms_layout) and return


    # http://stackoverflow.com/questions/21129587/ruby-on-rails-how-to-render-file-as-plain-text-without-any-html

    #render :plain will set the content type to text/plain

    #render :html will set the content type to text/html

    #render :body will not set the content type header.

    # render text: "some text". :plain does not work.

  end

  super
end

#my_set_meta(meta) ⇒ Object



34
35
36
37
38
# File 'lib/optimacms/mycontroller.rb', line 34

def my_set_meta(meta)
  @optimacms_meta_title = meta[:title]
  @optimacms_meta_keywords = meta[:keywords]
  @optimacms_meta_description = meta[:description]
end

#my_set_renderObject

included do

before_filter :my_set_render

end



9
10
11
12
# File 'lib/optimacms/mycontroller.rb', line 9

def my_set_render
  @is_optimacms = true

end

#my_set_render_template(tpl_view, tpl_layout) ⇒ Object



29
30
31
32
# File 'lib/optimacms/mycontroller.rb', line 29

def my_set_render_template(tpl_view, tpl_layout)
  @optimacms_tpl = tpl_view
  @optimacms_layout = tpl_layout
end