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