1
0

Simplified ingredient list preparation

This commit is contained in:
cryptogopher 2019-11-04 20:48:12 +01:00
parent fce6ee57b0
commit dd6b21d834

View File

@ -196,12 +196,11 @@ class IngredientsController < ApplicationController
end
def prepare_ingredients
@ingredients = filter_ingredients(@project.ingredients.includes(:ref_unit, :source))
@ingredients = filter_ingredients.includes(:ref_unit, :source)
end
def prepare_nutrients
ingredients = @project.ingredients.includes(:ref_unit, nutrients: [:quantity, :unit])
ingredients = filter_ingredients(ingredients)
ingredients = filter_ingredients.includes(nutrients: [:quantity, :unit])
@primary_quantities = @project.quantities.where(primary: true)
@primary_nutrients = {}
@extra_nutrients = {}
@ -218,8 +217,12 @@ class IngredientsController < ApplicationController
end
end
def filter_ingredients(ingredients)
def prepare_quantities(ingredients, quantities)
end
def filter_ingredients
filters = session[:filters] || {}
ingredients = @project.ingredients
if filters[:name].present?
ingredients = ingredients.where("name LIKE ?", "%#{filters[:name]}%")
end