Sha256: 24d351e9529e563f90f3c01ce3c1d945ee7d7507b4b3f460d84c9daadec95a36

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

module Refinery
  module Pages
    module InstanceMethods

      def self.included(base)
        base.send :helper_method, :refinery_menu_pages
        base.send :alias_method_chain, :render, :presenters
      end

      def error_404(exception=nil)
        if (@page = ::Refinery::Page.where(:menu_match => "^/404$").includes(:parts).first).present?
          # render the application's custom 404 page with layout and meta.
          if self.respond_to? :render_with_templates?
            render_with_templates? :status => 404
          else
            render :template => '/refinery/pages/show', :formats => [:html], :status => 404
          end
          return false
        else
          super
        end
      end

      # Compiles the default menu.
      def refinery_menu_pages
        ::Refinery::Menu.new(::Refinery::Page.fast_menu)
      end

    protected
      def render_with_presenters(*args)
        present(@page) unless admin? or @meta.present?
        render_without_presenters(*args)
      end

    private
      def store_current_location!
        return super if admin?

        session[:website_return_to] = refinery.url_for(@page.url) if @page && @page.persisted?
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-pages-2.0.10 lib/refinery/pages/instance_methods.rb
refinerycms-pages-2.0.9 lib/refinery/pages/instance_methods.rb
refinerycms-pages-2.0.8 lib/refinery/pages/instance_methods.rb
refinerycms-pages-2.0.7 lib/refinery/pages/instance_methods.rb
refinerycms-pages-2.0.6 lib/refinery/pages/instance_methods.rb