Class: Api::IngredientsController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::IngredientsController
- Defined in:
- app/controllers/alchemy/api/ingredients_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
Returns all ingredients as json object.
Instance Method Details
#index ⇒ Object
Returns all ingredients as json object
You can either load all or only these for :element_id or :page_id param
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/alchemy/api/ingredients_controller.rb', line 9 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 |