Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 :method=> :delete doesn't work in Internet Explorer

I am going through the rails 3 tutorial at railstutorial.org. I have just created an extremely simple scaffold Users.

The scaffold-generated destroy link does not work in Internet Explorer. It redirects to the show action instead of deleting the user.

This problem only happens in IE9 and IE8 (the only IE versions I've tested so far) The problem DOES NOT happen in Firefox. Can anyone tell me why this is happening?

The view:

<%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %>

Generated HTML:

<a href="/users/1" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a>

The controller:

def destroy
    @user = User.find(params[:id])
    @user.destroy

    respond_to do |format|
      format.html { redirect_to(users_url) }
      format.xml  { head :ok }
    end
end
like image 687
louis11 Avatar asked Dec 02 '22 04:12

louis11


1 Answers

In Rails 3.1 with the asset pipeline, all the javascript is in application.js. So, rather than :defaults, you need "application".

<%= javascript_include_tag "application" %>
like image 56
George Shaw Avatar answered Dec 06 '22 23:12

George Shaw