Sha256: c03fb8f5b37b03a517c6eed566041388a5ff7f0d79ead555c7b80ad65f3192cd

Contents?: true

Size: 805 Bytes

Versions: 3

Compression:

Stored size: 805 Bytes

Contents

class PagesController < ApplicationController
  def show

    raise ActionController::RoutingError.new("Page Not Found") if current_page.nil?

    if current_page.using_slug_backup?
      redirect_to current_page.url, status: :moved_permanently
    else
      # call controller hook
      self.send(current_page.identifier) if self.respond_to? current_page.identifier

      render "cardboard/pages/show", layout: @layout || "layouts/application"
    end
  end

private

  # def edit_link
  #   cardboard.edit_page_path(@page)
  # end
  # helper_method :edit_link

  def current_page
    @page ||= Cardboard::Page.find_by_url(params[:id]) || 
              Cardboard::Page.root || 
              raise(ActionController::RoutingError.new("No root page, make sure to run `rake cardboard:seed`"))
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cardboard_cms-0.1.8 app/controllers/pages_controller.rb
cardboard_cms-0.1.6 app/controllers/pages_controller.rb
cardboard_cms-0.1.4 app/controllers/pages_controller.rb