From 627f0488e5bd3c31359fc9e78acffbfea4a86a8b Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 24 Aug 2012 21:12:36 -0700 Subject: committed website v. 0.1.0 --- app/controllers/pages_controller.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/controllers/pages_controller.rb (limited to 'app/controllers/pages_controller.rb') diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb new file mode 100644 index 0000000..c86f313 --- /dev/null +++ b/app/controllers/pages_controller.rb @@ -0,0 +1,29 @@ +class PagesController < ApplicationController + + class PageNotFound < Exception; end + + layout :choose_layout + rescue_from ActionView::MissingTemplate, :with => :render_404 + rescue_from PageNotFound, :with => :render_404 + + def show + @page = StaticPage.find(params[:page]) + if @page + render_page(@page) + else + raise PageNotFound.new + end + end + + protected + + def choose_layout + if @page && @page.props.layout + @page.props.layout + else + 'application' + end + end + +end + -- cgit v1.2.3