views:

44

answers:

1

Hi all,

I'm getting this occacional error from my rails app:

ActionController::MethodNotAllowed: Only get, put, and delete requests are allowed.

I think it's caused by a malformed HTTP request (in this case a DELETE request) caused by the client browser... Maybe?

The URL that triggers this action it's like:

https://domain.com/resource/id/resource/id/resource/id.js?item_id=xxx

Which is generated by a helper like:

link_to_remote('delete', :url => resource_path(:id => @resource, :item_id => xxx, :format => :js), :method => :delete)

In some remote cases this crashes, I suspect that this happens only in IE (even IE8)...

If it is the case, what would be a solution? it supossed this should work in all browsers...

What do you suggest, guys?

Thanks for your help.

A: 

You can emulate a DELETE request with define the _method params to 'delete' and POST your request

shingara
Hi, I am currently doing that, the link looks like:<a onclick="new Ajax.Request('/resource/id/resource/id.js?item_id=xxx', {asynchronous:true, evalScripts:true, method:'delete'}); return false;" href="#"><img border="0" src="/images/delete.gif?1252605364" alt="Trash"></a>
Amed Rodriguez
That usually works, but in some cases -and I don't know why- the request is made via POST method and this launch the exeption.
Amed Rodriguez