Women in Technology

Hear us Roar



Article:
  Rolling with Ruby on Rails
Subject:   Homework #1 issues
Date:   2006-09-11 20:54:52
From:   m3_del
I am atempting to add a delete ("destroy") link at the end of the listing table. my HTML is as follows.



<html>
<head>
<title>All Recipes</title>
</head>
<body>


<h1>Online Cookbook - All Recipes</h1>
<table border="1">
<tr>
<td width="40%>

Recipe</td>
<td width="20%">

Category</td>
<td width="20%>

Date</td>
<td width="20%">

Delete</td>
</tr>

<% @recipes.each do |recipe| %>
<tr>
<td><%= link_to recipe.title, :action => "show", :id => recipe.id %></td>
<td><%= recipe.category.name %> </td>
<td><%= recipe.date %></td>
<td><%= link_to "Delete", :action => "destroy", :id => recipe.id %></td>
</tr>
<% end %>
</table>

<%= link_to "Create new recipe", :action => "new" %>



</body>
</html>

I believe I get the correct link but It just reloads the list view. In the original list view when you click destroy it gives you a popup to confirm deletion. What am I missing?

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Homework #1 issues
    2006-09-11 20:58:12  m3_del [View]

    <td><%= link_to "Delete", :action => "destroy", :id => recipe.id %></td>

    This is the line I am refering to in the above code. Sorry it seemed to format that all a little weird
    • Homework #1 issues
      2006-09-15 03:54:37  StBob [View]

      I've been laborating a bit with that stuff too and it seems like the destroy function want somekind of confirmation.


      <%= link_to "Delete", {:action => "destroy", :id => recipe.id },
      :confirm => 'Are you sure?', :post => true %>


      This code works, I don't really know why, but I think it is because of the :post => true snippet.

      I hope that helps.