Sha256: e825c755cdf6be490da8c46951615b7f97211f5f155855673128138255749b90

Contents?: true

Size: 762 Bytes

Versions: 5

Compression:

Stored size: 762 Bytes

Contents

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]
        @elements = @elements.where(page_id: params[:page_id])
      end
      if params[:named]
        @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

5 entries across 5 versions & 1 rubygems

Version Path
alchemy_cms-3.1.0.beta5 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.beta4 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.beta3 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.beta2 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.beta1 app/controllers/alchemy/api/elements_controller.rb