Class: StaticStuff::PagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/static_stuff/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#layout(layout = nil) ⇒ Object



3
4
5
6
7
# File 'app/controllers/static_stuff/pages_controller.rb', line 3

def layout layout = nil
  @layout = layout unless layout.nil?
  return 'application' if @layout.nil?
  @layout
end

#showObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/static_stuff/pages_controller.rb', line 11

def show
  template = File.join(
    File.basename(params[:controller]),
    params[:page]
  )

  html = render_to_string template, layout: false
  render text: html, layout: layout
rescue ActionView::MissingTemplate => error
  if error.message =~ %r{Missing template #{template}}
    message = "Static page not found. No route matches [GET] /#{template}"
    raise ActionController::RoutingError, message
  else
    raise error
  end
end