parsley/app/views/ingredients/index.json.jbuilder

20 lines
519 B
Plaintext
Raw Normal View History

2018-04-02 00:10:06 -05:00
2018-04-02 11:21:35 -05:00
json.cache_root! [Ingredient.all, @ingredients] do
2018-04-02 00:10:06 -05:00
2018-04-02 11:21:35 -05:00
json.extract! @ingredients, :total_count, :total_pages, :current_page
json.page_size @ingredients.limit_value
2018-04-02 00:10:06 -05:00
2018-04-02 11:21:35 -05:00
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
2018-04-02 00:10:06 -05:00
2018-04-02 11:21:35 -05:00
end
2018-04-02 00:10:06 -05:00
2018-04-02 11:21:35 -05:00
end