3

Following Michael Hartl's tutorial. Using Rails 3.0.9 under Ubuntu. The following header is in application.html.erb:

<head>
  <title><%= title %></title>
  <%= csrf_meta_tag %>
  <%= render 'layouts/stylesheets' %>
  <%= javascript_include_tag :defaults %>
</head>

No jQuery. Tutorial Listing 10.38 specifies the Delete action be called as follows:

<%= link_to "delete", user, :method => :delete, :confirm => "You sure?",
                            :title => "Delete #{user.name}" %>

Here is an example of the generated HTML:

<a href="/users/13" data-confirm="You sure?" data-method="delete" 
 rel="nofollow" title="Delete Mylene Gaylord">delete</a>

I've tested the confirmation under three browsers:

  • Firefox 3 under Ubuntu: "OK" deletes user, "Cancel" does not (good)
  • Firefox 5 under Win7: "OK" deletes user, "Cancel" does not (good)
  • IE8 under Win7: both "OK" and "Cancel" delete user (bad!)

When using IE8, why is Cancel calling the Delete code, and how do I fix it? Is there a way to test that Cancel does, in fact, cancel the action, no matter what browser is used?

Update 9/29/2011: after upgrading to Rails 3.1 and converting from Prototype to jQuery (Tutorial section 13.1.4), IE8 behaves properly: pressing Cancel aborts the delete action. However that doesn't answer the original question of why IE8 can't Cancel the delete from Rails 3.0.9 with Prototype.

Mark Berry
  • 17,843
  • 4
  • 58
  • 88
  • It seems that there's a similar question about the same subject in http://stackoverflow.com/questions/3772450/rails-3-method-delete-doesnt-work-in-internet-explorer – AndreDurao Jul 14 '11 at 20:14
  • Thanks @AndreDurao. I saw that but I think this is different. I'm not using jQuery, I'm using a later version of Rails, and I _do_ get the popups; it's just that in IE8, the Cancel button doesn't cancel the action. – Mark Berry Jul 15 '11 at 05:41

1 Answers1

0

Make sure you include this in you head.

app/views/layouts/application.html.erb

<!DOCTYPE html>
<html>
    <head>
        <%= csrf_meta_tag %>
    </head> 
    <body>
        HtML
    </body>
</html>     
thenengah
  • 42,557
  • 33
  • 113
  • 157