I'm trying to delete records from my table, but even if you delete them, you do not update the list with ajax:
enterprises_controller.rb
def destroy
@enterprise_tag.destroy
respond_to do |format|
if @enterprise_tag.destroy
format.html { redirect_to admin_dashboard_path, notice: "enterprise was remove successfully" }
format.js { render partial: "list" }
end
end
end
destroy.js.erb [Missing something qui? ]
<% if @enterprise_tag.errors.empty? %>
$("#items").append("<%= escape_javascript(render partial: 'list') %>");
<% end %>
index.html.erb
<% if @enterprise_tags.any? %>
<table id="items">
<tbody>
<tr>
<td>Nombre</td>
<td>Fecha de creacion</td>
<td colspan="2">Opciones</td>
</tr>
<% @enterprise_tags.each do |enterprise_tag| %>
<%= render partial: "enterprise_tags/list", locals: { enterprise_tag:enterprise_tag } %>
<% end %>
</tbody>
</table>
<% else %>
<div class="callout small text-center">
<span>No hay ningun registro disponible</span>
</div>
<% end %>
_list.html.erb
<tr>
<td><%= link_to enterprise_tag_path(enterprise_tag), method: :delete, data: { confirm: "¿Desea eliminar este registro?" }, remote: true do %><i class="fi-trash"></i><% end %></td>
</tr>