updating a resource

0 views
Skip to first unread message

Dan

unread,
Jul 16, 2008, 6:35:12 AM7/16/08
to sinatrarb
Hello,

I would like to update a resource from a form, but can't get the
correct action invoked when declared as

put ... do
...
end

works fine as

post ... do
...
end

the browser wants to post the form contents. What is the trick to
invoke the put action?

Thanks.

JW

unread,
Jul 16, 2008, 9:13:52 AM7/16/08
to sina...@googlegroups.com
I think modern browsers don't support PUT in <form>s (I think they do
using JavaScript's XMLHttpRequest). So, you just POST the form with a
hidden parameter _method set to 'put'. So, in your HTML, you write
something like:

<form method='post' action='/somewhere'>
<input type='hidden' name='_method' value='put' />
...
</form>

Then the browser uses POST, but Sinatra will interpret is as PUT.
(Sinatra developers: correct me if I'm wrong.)

JW

2008/7/16, Dan <dan...@gmail.com>:

blake.m...@gmail.com

unread,
Jul 16, 2008, 3:21:05 PM7/16/08
to sina...@googlegroups.com
JW,

That is correct.


--
Blake Mizerany
blake.m...@gmail.com

Reply all
Reply to author
Forward
0 new messages