Sha256: 4b6f4e2f010cbdfec186b9f4da2d24bd651881c9d15073b6add98af52098a1cb

Contents?: true

Size: 810 Bytes

Versions: 9

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  class Api::ElementsController < Api::BaseController
    # Returns all elements as json object
    #
    # You can either load all or only these for :page_id param
    #
    # If you want to only load a specific type of element pass ?named=an_element_name
    #
    def index
      @elements = Element.accessible_by(current_ability, :index)
      if params[:page_id].present?
        @elements = @elements.where(page_id: params[:page_id])
      end
      if params[:named].present?
        @elements = @elements.named(params[:named])
      end
      respond_with @elements
    end

    # Returns a json object for element
    #
    def show
      @element = Element.find(params[:id])
      authorize! :show, @element
      respond_with @element
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-4.0.6 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.5 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.4 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.3 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.2 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.1 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.0 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.0.rc2 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-4.0.0.rc1 app/controllers/alchemy/api/elements_controller.rb