Hi,
I have a ruby-on-rails application and I'm now wondering why RoR uses Restful Requests: eg. if you want delete an ressource it's a best practice to do it with such an HTTP Request:
DELETE /entry/13
you can also do it with with such an normal request:
GET /entry/delete/13
or GET /entry/13/delete
now my question: when i make a link to such an restful delete operation with the link_to helper
link_to :controller =>:delete, :id => id, :method => :delete
it results in some cryptic javascript:
<a href="/entry/13" 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);var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'GIep/wk5+6EMX23qY4TAP7joKy/G3f5uvMI6d6n9vlA='); f.appendChild(s);f.submit();return false;">Delete</a>
So whats the idea behind it? In my opinion you just exclude non-javascript users.