Skip to content

Instantly share code, notes, and snippets.

@universal
Forked from anonymous/gist:3917294
Created October 19, 2012 10:10
Show Gist options
  • Save universal/3917301 to your computer and use it in GitHub Desktop.
Save universal/3917301 to your computer and use it in GitHub Desktop.
ajax delete issue
$('#<%= dom_id(@match) %>').fadeOut();
<table>
<tr>
<th>Enemy Team</th>
<th>Date</th>
<th>Shift</th>
<th></th>
<th></th>
</tr>
<% @matches.each do |match| %>
<%= div_for match do %>
<tr>
<% if match.team_id == session[:team_id] %>
<td><%= match.enemy_team_id %></td>
<% else %>
<td><%= match.team_id %></td>
<% end %>
<td><%= match.date %></td>
<td><%= match.shift %></td>
<td><%= link_to 'Edit', edit_team_match_path(@team, match) %></td>
<td><%= link_to 'Destroy', [@team, match], method: :delete, remote: true %></td>
</tr>
<% end %>
<% end %>
</table>
<%= link_to "New Match", new_team_match_path(@current_team) %>
def destroy
@match = Match.find(params[:id])
@match.destroy
# redirect_to team_matches_url, :notice => "Match Deleted"
respond_to do |format|
format.html { redirect_to team_matches_url, :notice => "Match Deleted" }
format.json { head :ok }
format.js
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment