class DistrictsController < ApplicationController . . . def destroy @district = District.find(params[:id]) @district.destroy
respond_to do |format| format.html { redirect_to(districts_url) } format.xml { head :ok } end end
<% @districts.each do |district| %> <tr> <td><%= district.district_number %></td> <td><%= district.address %></td>
<td><%= link_to 'Show', district %></td> <td><%= link_to 'Edit', edit_district_path(district) %></td> <td><%= link_to 'Destroy', district, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %>
If I click on destroy link it shows me the district.