Sha256: bdc6329829855713ee96851f5ff23792d9c8173a00ebc61fad7e32c6818da596

Contents?: true

Size: 658 Bytes

Versions: 47

Compression:

Stored size: 658 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

47 entries across 47 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.3.3 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.3.2 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.7 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.3.1 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.3.0 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.6 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.5 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.1.12 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.0.15 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.4 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.1.11 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.3 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.1.10 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.2 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.1.9 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.0.14 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.2.1 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.0.13 app/controllers/alchemy/api/ingredients_controller.rb
alchemy_cms-7.1.8 app/controllers/alchemy/api/ingredients_controller.rb