Hi folks, I've been working on basic personal rails stuff for a bit now and have reached a point here I have the opportunity to develop something for my job. The basic scenario is this, take a half dozen or more php sites which all have forms; some of which vary, and populate a database. Use that data, re-assemble it and fire it off in xml to a bunch of other companies, grossly over simplified but that's why I want ruby at the core accepting data from csv, php, java and .net applications :) Now ideally I'd like to do it all in rails, clean start you see. Alas the frontends will stay in php etc for this iteration at least. Now I've been working on restful things for a while, peepcode to thank for that inspiration. Where I'm stuck is and I've seen a few posts on here, but is in how to glue these islands together. So how to send the data from app x into the rails app. At first it's a simple to say do a net::http_post of an xml block or the post vars into ruby, this works from some curl tests, but then security pops up, more over opening this up to other (approved) people/sites to post there form data to us. So I thought, api token type approach, I've never been a fan of storing username and passwords in streams, a key for some reason feels more acceptable, although a username is acceptable if it works ;). So I see these external sites posting data to the rails core, which is waiting for data, then manipulates it and sends it on again at some point. The rails app would have no external html interface, all api driven save for an admin app on another server taling to the same db. But I've got a mental block on how to achieve it, effectively and of course making it sustainable. I have my eye on the restful authentication and I'm exploring that this weekend I suspect. Does anybody have any pointers or tips, for the above scenario or code snippets to get me moving again, I've not done much integration in this way, save web services in java with wsdl/snore, just can't seem to wrap my head around the ruby way, which is frustrating me a bit... Thanks for reading, if you've got any questions, please ask.
on 2007-01-19 17:30
on 2007-09-26 00:39
Ok, it looks like restful is a way to go :) Using the restful_authentication from the svn and no before_filter I can do pretty much all we'll need :) I'm a little confused on the authentication, in particular to test using curl, so can anybody shed any light on this please? I've used the following syntax, but I get the could not authenticate you messages. My controller is programs with a before_filter login_required. curl attempts: curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' -u test:test -X POST -d "<program><title>t3</title><description>a test from the xml </description></program>" http://localhost:3000/programs/create curl -X GET --basic -u test:test -H "Accept: text/xml" http://localhost:3000/programs curl -H 'Accept: application/xml' -H 'Content-Type: application/xml' --basic -u test:test -X POST -d "<program><title>t3</title><description>a test from the xml </description></program>" http://localhost:3000/programs/create curl -H 'Accept:application/xml' -H 'Content-Type:application/xml' -X 'http://test:test@localhost:3000/programs'