Sha256: 7dc7c2f998c667543c8951b2f5d72311ba75fa165f7bfd9f548dd7a747b1ac40

Contents?: true

Size: 660 Bytes

Versions: 12

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  class Api::IngredientsController < Api::BaseController
    # Returns all ingredients as json object
    #
    # You can either load all or only these for :element_id or :page_id param
    #
    def index
      @ingredients = Alchemy::Ingredient.accessible_by(current_ability, :index)

      if params[:page_id].present?
        @ingredients = @ingredients
          .where(alchemy_page_versions: { page_id: params[:page_id] })
          .merge(Alchemy::PageVersion.drafts)
          .joins(element: :page_version)
      end

      render json: @ingredients, adapter: :json, root: "ingredients"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-6.1.10 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.9 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.8 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.7 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.6 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.5 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.4 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.0.0.pre.a app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.3 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.2 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.1 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-6.1.0 app/controllers/alchemy/api/ingredients_controller.rb