Forum: Ruby on Rails Creating Complex ActiveResource objects

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Carl F. (Guest)
on 2009-04-07 02:46
(Received via mailing list)
Given the following models:

class Uptime < ActiveRecord::Base
  has_many :pings
end

class Ping < ActiveRecord::Base
  belongs_to :uptime
end

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

class UptimeResource < ActiveResource::Base
  self.site = "http://localhost:3000"
  self.element_name = "uptime"
end

class PingResource < UptimeResource
  self.element_name = "ping"
end

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.

Carl
glennswest (Guest)
on 2009-04-07 12:17
(Received via mailing list)
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.
Carl F. (Guest)
on 2009-04-07 17:07
(Received via mailing list)
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 topic is locked and can not be replied to.