diff --git a/app/controllers/meals_controller.rb b/app/controllers/meals_controller.rb index 0f6c42b..9808113 100644 --- a/app/controllers/meals_controller.rb +++ b/app/controllers/meals_controller.rb @@ -44,6 +44,7 @@ class MealsController < ApplicationController end def destroy + flash[:notice] = 'Deleted meal' if @meal.destroy end def edit_notes diff --git a/app/views/meals/_index.html.erb b/app/views/meals/_index.html.erb index 8a4f246..16ade3a 100644 --- a/app/views/meals/_index.html.erb +++ b/app/views/meals/_index.html.erb @@ -4,7 +4,7 @@ <% @meals.group_by { |m| m.eaten_at ? m.eaten_at.to_date : Date.current } .sort_by {|k,v| k }.reverse.each do |date, meals| %> - +

<%= date == Date.current ? 'Today' : date.strftime('%F') %>

diff --git a/app/views/meals/_show.html.erb b/app/views/meals/_show.html.erb index c1ba01d..c745806 100644 --- a/app/views/meals/_show.html.erb +++ b/app/views/meals/_show.html.erb @@ -32,7 +32,7 @@ <% end %> <% end %> - + <% end %> diff --git a/app/views/meals/destroy.js.erb b/app/views/meals/destroy.js.erb new file mode 100644 index 0000000..88e0db4 --- /dev/null +++ b/app/views/meals/destroy.js.erb @@ -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 %>