Sha256: 76aa826722eaeb481f7aff0479ee4c24d57635a96a79397263f0c193dbf4168c
Contents?: true
Size: 1.08 KB
Versions: 9
Compression:
Stored size: 1.08 KB
Contents
class PagesController < SlicesController caches_page :virtual_error_pages def virtual_error_pages role = Page.role_for_status(params[:status]) if role render_page(Page.find_virtual(role), 200) # page is only cached if status is 200 else raise Page::NotFound.new(request.path) end end def create page = Page.find_by_path(request.path) raise Page::NotFound unless page.active? slice = post_slice(page) if slice.handle_post(params) slice.set_success_message(flash) redirect_to(slice.redirect_url) else render_page(page) end end def show page = nil benchmark 'Page.find_by_path' do page = Page.find_by_path(request.path) raise Page::NotFound unless page.active? end render_page(page) end private def post_slice(page) page.slices.detect { |s| s.respond_to?(:handle_post) }.tap do |slice| slice.nil? && (raise RuntimeError.new("page can't handle POST data")) slice.setup({ renderer: self, current_page: page }) end end end
Version data entries
9 entries across 9 versions & 1 rubygems