Sha256: 93a0040c386423400b4e23f7306ac60991cdb2a7a986d2e3ee07b00f5b612ba2

Contents?: true

Size: 762 Bytes

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
alchemy_cms-3.1.3 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.1 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.rc3 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.rc2 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.rc1 app/controllers/alchemy/api/elements_controller.rb
alchemy_cms-3.1.0.beta6 app/controllers/alchemy/api/elements_controller.rb