parsley/app/views/ingredients/index.json.jbuilder
2018-04-02 11:21:35 -05:00

20 lines
519 B
Ruby

json.cache_root! [Ingredient.all, @ingredients] do
json.extract! @ingredients, :total_count, :total_pages, :current_page
json.page_size @ingredients.limit_value
json.ingredients @ingredients do |i|
json.extract! i, :id, :name, :ndbn, :kcal
json.usda i.ndbn.present?
if i.density.present?
value = UnitConversion::parse(i.density)
json.density value.convert('oz/cup').change_formatter(UnitConversion::DecimalFormatter.new).pretty_value
else
json.density nil
end
end
end