views:

124

answers:

1

I have code like this in a Rails 3 app I'm working on

    <% @positions.each do |position|  %>
    <tr class="<%= cycle("", "alternate") %>">
        <td><%= position.name %></td>
        <td class="actions">
            <%=link_to 'edit', edit_position_path(position), :class => 'edit' %> |
            <%=link_to 'delete', position_path(position), :confirm => 'Are you sure you want to delete this item?', :method => 'delete' %>
        </td>
    </tr>
    <% end %>

The edit link works fine, but the delete link keeps taking me to the show action.
Any idea what the problem is?

PS: I'm using formtastic in tandem with Mongoid and ActiveRecord isn't loaded in my config/application.rb file.

+1  A: 

Rails 3 is using unobstrusive javascript to handle delete so you may need to add the following into your layout:

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>

Check out railscasts 205 to see how to use jquery instead of prototype.

JohnDel
Haven't tried this yet, but if its true then it strikes me as rather daft to have to include javascript files in all my Rails projects just to get basic Restful functionality. yuck.
concept47