Creating Complex ActiveResource objects

Given the following models:

class Uptime < ActiveRecord::Base
has_many :pings

class Ping < ActiveRecord::Base
belongs_to :uptime

I can create an ActiveResource that will get the uptimes and ping

class UptimeResource < ActiveResource::Base = “http://localhost:3000
self.element_name = “uptime”

class PingResource < UptimeResource
self.element_name = “ping”

If the information exists in the database, I can do
UptimeResource.find(1).pings and get a list of pings. But how can I
create pings besides creating an UptimeResource and then creating the
pings separately. I am trying to save the XML into an XML Database and
bypass a relational database (client requirements). I wish I had
something like CouchDB_fu but for XML databases…

Is this a job for DataMapper? I am open to any strategy. Swift kicks
to the head welcome.


Yes you would normally update pings as they occur, unless your
thinking of submitting
a xml and doing a bulk update. So the “pinger” is doing a butch of
pings, then
sending the results to the backend?
Then you just need to convert a local array to a xml file and submit
it to your Restful web app.

The “convert a local array to xml” is where I am running into issues.
I keep trying to set a “pings” property but it isn’t working. How do I
shove that into the Uptime object so that they are all transmitted at
the same time?

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