Module: Cmtool::Includes::PagesController
- Defined in:
- lib/cmtool/includes/pages_controller.rb
Instance Method Summary collapse
- #home ⇒ Object
- #not_found ⇒ Object
-
#show ⇒ Object
General catcher for pages.
Instance Method Details
#home ⇒ Object
4 5 6 7 8 9 |
# File 'lib/cmtool/includes/pages_controller.rb', line 4 def home page_name = "home" @page = ::Page.find_by_name_and_locale(page_name, I18n.locale) || ::Page.new(:name => page_name, locale: I18n.locale) @sub_pages = @page.children.select{|child| child..present? } render :template => "pages/#{page_name}", :layout => @page.layout.presence || ::Page.layouts.first.to_s end |
#not_found ⇒ Object
26 27 28 29 30 |
# File 'lib/cmtool/includes/pages_controller.rb', line 26 def not_found @page = ::Page.find_by_name_and_locale('404', I18n.locale) || ::Page.new(name: '404', body: "404 Page Not Found") @sub_pages = [] render template: 'pages/404', layout: @page.layout.presence || ::Page.layouts.first.to_s, status: 404 end |
#show ⇒ Object
General catcher for pages
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cmtool/includes/pages_controller.rb', line 12 def show @page = ::Page.find_by_name_and_locale(params[:name], I18n.locale) not_found and return unless @page @sub_pages = [@page] + @page.children.select{|child| child..present? } template = "pages/#{@page.name}" if template_exists?(template) render :template => template, :layout => @page.layout.presence || ::Page.layouts.first return else render :layout => @page.layout.presence || ::Page.layouts.first end end |