On Jan 21, 2:19 pm, David Sainte-claire
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> To start off, I don''t know if this is unorthodox, or if someone
has had
> to implement something similar. I''ve searched all over Google and
don''t
> really a see a good solution for what I''m trying to do.
>
> Basically I created my own plugin that subclasses ActiveResource so that
> I can consume non-REST URIs and get back XML. That''s easy, there
are
> lots of exmaples online of how to do that. Basically, I then use a gem
> called happymapper to bind the XML to Ruby objects. Again, this works
> very easily as well. Now here''s where I''m stuck. I want
to persist the
> Ruby object to a local database so that I don''t have to go out and
get
> it again. I had a thought of using the save method from ActiveRecord
> since all the DB plumbing is built in, but I''m a little bit at a
loss as
> to how I can call ActiveRecords''s save method from a subclass of
> ActiveResource as Ruby doesn''t allow multiple inheritance.
>
> Has anyone else needed to use ActiveResource to extract data, and then
> come up with a method to persist that data to a local DB? Using the
> ActiveResource save method will attempt to POST it back to the place
> where I got it, and it''s a read-only resource.
>
Depending on the object, serializing (either to YAML or Marshal
format) might work. Then you''d just store the whole serialized object
(now basically a BLOB) to the DB.
Not sure how well ActiveResource plays with serialization, but it''s
worth a try.
--Matt Jones
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.