update ingredient list
This commit is contained in:
parent
c0d43171a4
commit
30726ec1b8
17
app/decorators/ingredient_decorator.rb
Normal file
17
app/decorators/ingredient_decorator.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class IngredientDecorator < BaseDecorator
|
||||
|
||||
def ndbn_check
|
||||
if ndbn.present?
|
||||
"<span class =\"glyphicon glyphicon-ok\"></span>".html_safe
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def density
|
||||
if wrapped.density.present?
|
||||
value = UnitConversion::parse(wrapped.density)
|
||||
value.convert('oz/cup').change_formatter(UnitConversion::DecimalFormatter.new).pretty_value
|
||||
end
|
||||
end
|
||||
end
|
@ -16,22 +16,22 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>USDA NDBN</th>
|
||||
<th>USDA</th>
|
||||
<th>KCal per 100g</th>
|
||||
<th>Density</th>
|
||||
<th>Density (oz/cup)</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @ingredients.each do |ingredient| %>
|
||||
<% decorate(@ingredients, IngredientDecorator).each do |ingredient| %>
|
||||
<tr>
|
||||
<td><%= link_to ingredient.name, edit_ingredient_path(ingredient) %></td>
|
||||
<td><%= ingredient.ndbn %></td>
|
||||
<td><%= ingredient.ndbn_check %></td>
|
||||
<td><%= ingredient.kcal %></td>
|
||||
<td><%= ingredient.density %></td>
|
||||
<td>
|
||||
<%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' do %>
|
||||
<%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %>
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
<% end %>
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user