How do I serialize data for a controller action

I have two instances of a intranet Rails application running on
different networks. The database design for each
is the same, but the data is different.

I occasionally need for certain database records to be copied from
application to another.
I would like to serialize the records and send the data to the 2nd
application’s web server , where
a controller action would unserialize the records, process them and
store in the 2nd database.

I am not sure how to do this. Any ideas?

Don Mc

It sounds like what you might be asking for is marshaling. I haven’t
tried it, but here’s a reference:


Or you could follow the hot trend in rails and just have them talk to
each other via REST.

There’s support in the current version of rails for scaffolding
(generating) your models as “resources”, which means you get basic
controller actions that return xml of your object if called as a REST

ActiveRecord will also do basic serialization to xml out of the box. If
your needs are fairly straightforward, this can be a very quick thing to

Oh, and there’s also ActiveResource, a REST client library that allows
you to use the models from one app in another by making the REST calls
for you behind the scenes.

And finally, since it’s been a hot topic, there’s lots of information
out there about RESTful rails…


Paul and Ben,
Thanks for the help!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs