Sha256: ab0578e1ebfb6e2168b86ed9e4e61bee7057e416f43dd92b98c70789705fcf03

Contents?: true

Size: 764 Bytes

Versions: 6

Compression:

Stored size: 764 Bytes

Contents

module Alchemy
  class Api::PagesController < Api::BaseController
    before_action :load_page, only: [:show]

    # Returns all pages as json object
    #
    def index
      @pages = Page.accessible_by(current_ability, :index)
      if params[:page_layout].present?
        @pages = @pages.where(page_layout: params[:page_layout])
      end
      respond_with @pages
    end

    # Returns a json object for page
    #
    # You can either load the page via id or its urlname
    #
    def show
      authorize! :show, @page
      respond_with @page
    end

    private

    def load_page
      @page = Page.find_by(id: params[:id]) ||
              Page.find_by(urlname: params[:urlname]) ||
              raise(ActiveRecord::RecordNotFound)
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 app/controllers/alchemy/api/pages_controller.rb
lc_alchemy_cms-3.2.1 app/controllers/alchemy/api/pages_controller.rb
lc_alchemy_cms-3.2.0 app/controllers/alchemy/api/pages_controller.rb
alchemy_cms-3.2.0 app/controllers/alchemy/api/pages_controller.rb
alchemy_cms-3.2.0.rc1 app/controllers/alchemy/api/pages_controller.rb
alchemy_cms-3.2.0.beta app/controllers/alchemy/api/pages_controller.rb