I using "form method=POST action=/goo/3/" to say update instance 3 via a POST. But I'm using a URL like foo?delete=3 to delete item 3 i.e. using a GET to delete an instance. This is because the URL is a href link in a table of entries (actually a
little cross image being a delete icon). It's easy to do it this way.

The question is if this is supposed to be done via a POST how does one do it without
using a form?

Rails tackles this by calling javascript that creates and submits a form to the href in the anchor, which gives you links that POST. The one downfall of this approach is users that have no javascript, or javascript disabled use GET to perform deletes;

<a href="/lend/destroy/1"
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;
        f.submit();
};
return false;">Destroy</a>

Hope that helps,
Rob.
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to