1
0

Added MealsController#destroy

This commit is contained in:
cryptogopher 2020-04-24 00:54:32 +02:00
parent dfeb9af6db
commit 5ab17cf69b
4 changed files with 7 additions and 2 deletions

View File

@ -44,6 +44,7 @@ class MealsController < ApplicationController
end end
def destroy def destroy
flash[:notice] = 'Deleted meal' if @meal.destroy
end end
def edit_notes def edit_notes

View File

@ -4,7 +4,7 @@
<% @meals.group_by { |m| m.eaten_at ? m.eaten_at.to_date : Date.current } <% @meals.group_by { |m| m.eaten_at ? m.eaten_at.to_date : Date.current }
.sort_by {|k,v| k }.reverse.each do |date, meals| %> .sort_by {|k,v| k }.reverse.each do |date, meals| %>
<tr id="day-<%= date.strftime('%Y%m%d') %>" class="date"> <tr id="day-<%= date.strftime('%Y%m%d') %>" class="date">
<td class="date" colspan="2"> <td class="date" colspan="6">
<h3><%= date == Date.current ? 'Today' : date.strftime('%F') %></h3> <h3><%= date == Date.current ? 'Today' : date.strftime('%F') %></h3>
</td> </td>
</tr> </tr>

View File

@ -32,7 +32,7 @@
<% end %> <% end %>
<% end %> <% end %>
</td> </td>
<td></td> <td colspan="2"></td>
</tr> </tr>
<% end %> <% end %>
</tr> </tr>

View File

@ -0,0 +1,4 @@
<% if @meal.destroyed? %>
$('tr[id=meal-<%= @meal.id %>]').nextUntil(':not(.ingredient)').addBack().remove();
$('#meals').find('tr.date + tr.date').prev().remove();
<% end %>