Simplified ingredient list preparation
This commit is contained in:
parent
fce6ee57b0
commit
dd6b21d834
@ -196,12 +196,11 @@ class IngredientsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prepare_ingredients
|
def prepare_ingredients
|
||||||
@ingredients = filter_ingredients(@project.ingredients.includes(:ref_unit, :source))
|
@ingredients = filter_ingredients.includes(:ref_unit, :source)
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_nutrients
|
def prepare_nutrients
|
||||||
ingredients = @project.ingredients.includes(:ref_unit, nutrients: [:quantity, :unit])
|
ingredients = filter_ingredients.includes(nutrients: [:quantity, :unit])
|
||||||
ingredients = filter_ingredients(ingredients)
|
|
||||||
@primary_quantities = @project.quantities.where(primary: true)
|
@primary_quantities = @project.quantities.where(primary: true)
|
||||||
@primary_nutrients = {}
|
@primary_nutrients = {}
|
||||||
@extra_nutrients = {}
|
@extra_nutrients = {}
|
||||||
@ -218,8 +217,12 @@ class IngredientsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_ingredients(ingredients)
|
def prepare_quantities(ingredients, quantities)
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_ingredients
|
||||||
filters = session[:filters] || {}
|
filters = session[:filters] || {}
|
||||||
|
ingredients = @project.ingredients
|
||||||
if filters[:name].present?
|
if filters[:name].present?
|
||||||
ingredients = ingredients.where("name LIKE ?", "%#{filters[:name]}%")
|
ingredients = ingredients.where("name LIKE ?", "%#{filters[:name]}%")
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user