Hello,
I am sure this is a simple problem but for some reason I can’t get it
to work.
I am trying to delete a record. My routes.rb has:
map.resources :ads
…the AdsController has:
def destroy
@ad = Ad.find(params[:id])
@ad.destroy
respond_to do |format|
format.html { redirect_to(ads_url) }
format.xml { head :ok }
end
end
…and the index.html.erb has:
-
<% @ads.each do |ad| %>
- <%= link_to h(ad.name), ad %> [<%= link_to "Delete", ads_path (ad), :method => :destroy %>] <% end %>
But instead of destroying a record, it creates a new empty record.
Also, when looking at the url of ‘Delete’ I get
http://localhost:3000/ads.%23<ad:0x24681b8>
TIA,
Elle