1
0

Changed Ingredient#destroy to ajax

This commit is contained in:
cryptogopher 2019-11-02 18:50:14 +01:00
parent c7c39be017
commit 3689abb1dc
4 changed files with 5 additions and 5 deletions

View File

@ -41,12 +41,12 @@ class IngredientsController < ApplicationController
end
def destroy
# FIXME: redirect to :back?
# FIXME: don't destroy if any meal depend on ingredient
if @ingredient.destroy
flash[:notice] = 'Deleted ingredient'
end
redirect_to project_ingredients_url(@project)
prepare_ingredients
render :toggle
end
def toggle

View File

@ -27,7 +27,9 @@
<%= i.source.name if i.source.present? %>
<%= ", #{i.source_ident}" if i.source_ident.present? %>
</td>
<td class="action"><%= delete_link ingredient_path(i), data: {} %></td>
<td class="action">
<%= delete_link ingredient_path(i), {remote: true, data: {}} %>
</td>
</tr>
<% end %>
</tbody>

View File

@ -1 +0,0 @@
<h2>IngredientsController#create</h2>

View File

@ -1 +0,0 @@
<h2>IngredientsController#destroy</h2>