views:

481

answers:

2

I have to pass parameters between two rails apps. In one side (sender) I have an array of hashes. I have a code like the following to send the data:

   http = Net::HTTP.new('localhost', '3030')
   result = http.post('/processar_lotes', my_array_of_hashes)

Some questions

  • Is there any (kind of) serialize or something like this that I can pass to the other app?
  • At the other side, how can I de-serialize the information?
  • Is there a limit to the size of what I pass as a parameter?
A: 

Probably not the answer you're looking for, but I'd use XML. This would make your application much more flexible than using language-specific serialization.

It shouldn't be too hard to convert the array to XML and back.

EDIT: You might wanna check out ROXML and XML::Mapping.

Can Berk Güder
+1  A: 

To answer your questions:

  • There are many ways to 'serialize' the data. You can use your own custom format, or use a standard one. For example, you can try to use the Rails to_xml method, or the to_json method. You can also use Ruby's Marshal object.
  • Depending on your choice, this might be from_json, from_xml, Marshal.load, or your own custom reader.
  • Normally, this is unlimited for HTTP posts, but depending on your server configuration, it could be less.
Jeroen Heijmans