summaryrefslogtreecommitdiff
path: root/app/controllers/pages_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/pages_controller.rb')
-rw-r--r--app/controllers/pages_controller.rb29
1 files changed, 29 insertions, 0 deletions
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
+