Skip to content

Instantly share code, notes, and snippets.

@nicolasblanco
Created May 6, 2009 10:06
Show Gist options
  • Select an option

  • Save nicolasblanco/107468 to your computer and use it in GitHub Desktop.

Select an option

Save nicolasblanco/107468 to your computer and use it in GitHub Desktop.
This :
<%= link_to "Delete", @comment, :method => :delete %>
With Rails 2 :
<a href="/comments/1" onclick="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);f.submit();return false;">Destroy</a>
With Rails 3 :
<a href="/comments/1" data-method="delete">Destroy</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment