unicorn_crack
unicorn_crack

Reputation: 1099

Using XML as a datasource for Rails models

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.

Upvotes: 4

Views: 1008

Answers (2)

Codebeef
Codebeef

Reputation: 43996

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

Upvotes: 4

Gabriel L. Oliveira
Gabriel L. Oliveira

Reputation: 4062

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.

Upvotes: -1

Related Questions