parsley/app/views/recipes/show.json.jbuilder

31 lines
808 B
Plaintext
Raw Normal View History

2018-04-01 21:43:23 -05:00
json.extract! @recipe, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at, :step_text
json.rendered_steps MarkdownProcessor.render(@recipe.step_text)
json.tags @recipe.tag_names
json.ingredients @recipe.recipe_ingredients do |ri|
json.extract! ri, :id, :ingredient_id, :display_name, :name, :quantity, :units, :preparation, :sort_order
json.ingredient do
if ri.ingredient.nil?
json.null!
else
json.extract! ri.ingredient, :id, :name, :density, :notes
end
end
json._destroy false
end
json.nutrition_data do
json.errors @recipe.nutrition_data.errors
json.nutrients NutritionData::NUTRIENTS.select { |_, v| v.present? } do |name, label|
json.name name
json.label label
json.value @recipe.nutrition_data.send(name)
end
end