Changed Ingredient#destroy to ajax
This commit is contained in:
parent
c7c39be017
commit
3689abb1dc
@ -41,12 +41,12 @@ class IngredientsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
# FIXME: redirect to :back?
|
|
||||||
# FIXME: don't destroy if any meal depend on ingredient
|
# FIXME: don't destroy if any meal depend on ingredient
|
||||||
if @ingredient.destroy
|
if @ingredient.destroy
|
||||||
flash[:notice] = 'Deleted ingredient'
|
flash[:notice] = 'Deleted ingredient'
|
||||||
end
|
end
|
||||||
redirect_to project_ingredients_url(@project)
|
prepare_ingredients
|
||||||
|
render :toggle
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle
|
def toggle
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
<%= i.source.name if i.source.present? %>
|
<%= i.source.name if i.source.present? %>
|
||||||
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
||||||
</td>
|
</td>
|
||||||
<td class="action"><%= delete_link ingredient_path(i), data: {} %></td>
|
<td class="action">
|
||||||
|
<%= delete_link ingredient_path(i), {remote: true, data: {}} %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<h2>IngredientsController#create</h2>
|
|
@ -1 +0,0 @@
|
|||||||
<h2>IngredientsController#destroy</h2>
|
|
Reference in New Issue
Block a user