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

18 lines
440 B
Plaintext
Raw Normal View History

2018-04-02 00:10:06 -05:00
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