views:

15

answers:

2

Is there a way to use external XML (or JSON) as a datasource for models in Rails. E.g. some models use the database for getting data, others "ping" external services for XML.

A: 

You could override the 'get' methods on the model, to look at your xml (or xml server) instead of looking at the database.
To parse xml on ruby, there are many apis, like rexml and xmlsimple.
Here there's a comparison between both.

Gabriel L. Oliveira
+2  A: 

You can use ActiveResource for this - it's already part of Rails, and is intended to allow you to integrate with external restful services.

Mr. Matt
This looks like it, thanks!
IvanBernat