Hello, I''m not yet a camping guru nor a RESTafarian, but I try. Currently I''m trying to build a rest-style web app with sleeping bag/camping and I may successfully access the index, show, new, create and edit methods, that are provided with sleeping bag. But I don''t know, how to build a form or link to access destroy and update. I think this is mainly because of the corresponding HTTP verbs, that are supposed to be used. But unfortunately PUT and DELETE are not supported by browsers. In Rails, these are simulated with a hidden field "method" that contains these meta information. In the Mailing List Archive a found a hint, that sleeping bag would use a hidden field "_verb" respectively, but I cannot make it work, neither can I find any hints on that issue in the source of sleeping bag. Does anybody know, how I can build a link/form to update and destroy? Thanks for these great tools, both camping and sleeping bag feel as lightweight as it gets. Cheers, Gregor
Mark Fredrickson
2007-Jun-22 15:16 UTC
Simulate HTTP put and delete in Camping/SleepingBag
Hi Gregor, Take a look at: http://osdir.com/ml/lang.ruby.camping.general/2006-11/msg00008.html I''m not familiar with sleeping bag (link?) but perhaps this will help. -M On 6/22/07, Gregor Schmidt <ruby at schmidtwisser.de> wrote:> Hello, > > I''m not yet a camping guru nor a RESTafarian, but I try. > > Currently I''m trying to build a rest-style web app with sleeping > bag/camping and I may successfully access the index, show, new, create > and edit methods, that are provided with sleeping bag. But I don''t > know, how to build a form or link to access destroy and update. > > I think this is mainly because of the corresponding HTTP verbs, that > are supposed to be used. But unfortunately PUT and DELETE are not > supported by browsers. In Rails, these are simulated with a hidden > field "method" that contains these meta information. In the Mailing > List Archive a found a hint, that sleeping bag would use a hidden > field "_verb" respectively, but I cannot make it work, neither can I > find any hints on that issue in the source of sleeping bag. > > Does anybody know, how I can build a link/form to update and destroy? > > Thanks for these great tools, both camping and sleeping bag feel as > lightweight as it gets. > > Cheers, > > Gregor > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
Hi Mark, Thanks for the tip, with the help of this snippet, the actions are routed correctly. SleepingBag is a REST-API for Camping, that I stumbled upon on this mailing list, I guess. It provides you with rails-like routing to the standard REST methods for your controllers. Unfortunately, there is not a lot of documentation, but the specs and the given example is quite sufficient. You may find it at http://code.google.com/p/sleepingbag/ and in this list at http://www.mail-archive.com/camping-list at rubyforge.org/msg00150.html with some introductory words. Best, Gregor On 6/22/07, Mark Fredrickson <mark.m.fredrickson at gmail.com> wrote:> Hi Gregor, > > Take a look at: > > http://osdir.com/ml/lang.ruby.camping.general/2006-11/msg00008.html > > I''m not familiar with sleeping bag (link?) but perhaps this will help. > > -M > > > On 6/22/07, Gregor Schmidt <ruby at schmidtwisser.de> wrote: > > Hello, > > > > I''m not yet a camping guru nor a RESTafarian, but I try. > > > > Currently I''m trying to build a rest-style web app with sleeping > > bag/camping and I may successfully access the index, show, new, create > > and edit methods, that are provided with sleeping bag. But I don''t > > know, how to build a form or link to access destroy and update. > > > > I think this is mainly because of the corresponding HTTP verbs, that > > are supposed to be used. But unfortunately PUT and DELETE are not > > supported by browsers. In Rails, these are simulated with a hidden > > field "method" that contains these meta information. In the Mailing > > List Archive a found a hint, that sleeping bag would use a hidden > > field "_verb" respectively, but I cannot make it work, neither can I > > find any hints on that issue in the source of sleeping bag. > > > > Does anybody know, how I can build a link/form to update and destroy? > > > > Thanks for these great tools, both camping and sleeping bag feel as > > lightweight as it gets. > > > > Cheers, > > > > Gregor > > _______________________________________________ > > Camping-list mailing list > > Camping-list at rubyforge.org > > http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
On Fri Jun 22, 2007 at 04:51:37PM +0200, Gregor Schmidt wrote:> Hello, > > I''m not yet a camping guru nor a RESTafarian, but I try. > > Currently I''m trying to build a rest-style web app with sleeping > bag/camping and I may successfully access the index, show, new, create > and edit methods, that are provided with sleeping bag. But I don''t > know, how to build a form or link to access destroy and update. > > I think this is mainly because of the corresponding HTTP verbs, that > are supposed to be used. But unfortunately PUT and DELETE are not > supported by browsers.WebKit and Firefox both take just about any string as the method name. at least if youre submitting with XHR which is good, because then you can use appropriately named methods in your camping app, instead of laying things inside other protocols (Atom/Bayeux) or resorting to URL and form field hacks (Rails)..> I cannot make it work, neither can I > find any hints on that issue in the source of sleeping bag.if you want to emulate rails. why not just use Rails? do you like jumping through hoops to be tied to arbitrary ORMs* and additionally emulations of said ORMs frontend-facilitating features on another framework? * and ORMs that tie you to a static schema and want you to only update it once every quarter during a migration-festival and hope you got all the new fields right... and the fields are just arbitrary strings rather than anything more meaningful to the web at large..> Does anybody know, how I can build a link/form to update and destroy?i generate the form clientside, cache the old value, and submit PATCH methods with the new value. this makes more sense than PUT, but PATCH appeared in some draft version f the HTTP1.1 RFC then disappeared, or something. im pretty sure mongrel was trying to eat anything that wasnt PUT/POST/GET last i tried though. i think i may have reluctantly switched to a less sensical name beacuse i couldnt figure out how to make mongrel not toss the reqs.. as for REST, i tend to just use the request URI as an implicit subject (object ID) for the other operations. it helps if youre using HTTP URIs for everything including properties, otherwise you have to have a mapping layer somewhere.> > Thanks for these great tools, both camping and sleeping bag feel as > lightweight as it gets. > > Cheers, > > Gregor > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list