Hi all As we all know, in REST the ResourceController#delete action is called by calling "/resources/:id" with a delete method. But, the delete method is not supported in IE. This seems like a problem to me. How do people get around this, typically? I can think of various ways around it but they all seem a bit bodgy and i''d like to know some other approaches or even if there''s something really obvious that i''m missing. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi,
You just cat you following in your view:
<%= link_to ''Destroy'', photo, :confirm => ''Are
you sure?'', :method
=> :delete %>
and it appear in browser to that:
<a onclick="if (confirm(''Are you sure?'')) { var f
document.createElement(''form''); f.style.display =
''none'';
this.parentNode.appendChild(f); f.method = ''POST''; f.action
this.href;var m = document.createElement(''input'');
m.setAttribute(''type'', ''hidden'');
m.setAttribute(''name'', ''_method'');
m.setAttribute(''value'', ''delete'');
f.appendChild(m);var s document.createElement(''input'');
s.setAttribute(''type'', ''hidden'');
s.setAttribute(''name'',
''authenticity_token'');
s.setAttribute(''value'',
''LgNwcxaXQ3+NT95f1SJYo1ZOUfXMFtQimzSzDmjJM3g='');
f.appendChild(s);f.submit(); };return false;" href="/photos/
51">Destroy</a>
as you can see its still post, but it has hidden input that tells your
controller about delete.
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
*your just CAN ADD (sorry for this typo).... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
by the way, the same story about PUT
<form method="post" id="edit_photo_51"
class="edit_photo" action="/
photos/51">
      <div style="margin: 0pt; padding: 0pt; display: inline;">
          <input type="hidden" value="put"
name="_method">
           <input type="hidden"
value="LgNwcxaXQ3+NT95f1SJYo1ZOUfXMFtQimzSzDmjJM3g="
name="authenticity_token">
        </div>
..........
  <p>
    <input type="submit" value="Update"
name="commit"
id="photo_submit">
  </p>
</form>
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Max Williams
2010-Mar-17  10:59 UTC
Re: REST, Internet Explorer and the banned DELETE method
DmitryPush wrote:> Hi, > You just cat you following in your view: > <%= link_to ''Destroy'', photo, :confirm => ''Are you sure?'', :method > => :delete %> > and it appear in browser to that: > <a onclick="if (confirm(''Are you sure?'')) { var f > document.createElement(''form''); f.style.display = ''none''; > this.parentNode.appendChild(f); f.method = ''POST''; f.action > this.href;var m = document.createElement(''input''); > m.setAttribute(''type'', ''hidden''); m.setAttribute(''name'', ''_method''); > m.setAttribute(''value'', ''delete''); f.appendChild(m);var s > document.createElement(''input''); s.setAttribute(''type'', ''hidden''); > s.setAttribute(''name'', ''authenticity_token''); s.setAttribute(''value'', > ''LgNwcxaXQ3+NT95f1SJYo1ZOUfXMFtQimzSzDmjJM3g=''); > f.appendChild(s);f.submit(); };return false;" href="/photos/ > 51">Destroy</a> > > as you can see its still post, but it has hidden input that tells your > controller about delete.Ah yes, of course, i had the feeling that rails handled this with a bit of subterfuge but couldn''t remember quite how. I actually tried this with a link_to_remote and the generated html was just a call to jQuery.ajax with the delete method, just as i''d done it already, rather than the code you posted up. I wonder if this is an issue with the jrails plugin, which overrides the javascript generated by rails'' remote helpers. I''m actually doing it in javascript (in a jQuery.ajax call) anyway, so lets see if changing the method to post and adding "_method=delete" to the data has the same effect...yes it does. Great, thanks Dmitry! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.