Added MealsController#destroy
This commit is contained in:
parent
dfeb9af6db
commit
5ab17cf69b
@ -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
|
||||||
|
@ -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>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td colspan="2"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
4
app/views/meals/destroy.js.erb
Normal file
4
app/views/meals/destroy.js.erb
Normal 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 %>
|
Reference in New Issue
Block a user