views:

73

answers:

1

I've been googling for a while to try and convert and incoming XML request into an active record object. I've tried using the ActiveRecordObject.new.from_xml method but it doesn't seem to handle relationships.

For example, say I have the following xml:

<blog>
  <title></title>
  <blog-pages>
    <blog-page>
      <page-number></page-number>
      <content></content>
    </blog-page>
  </blog-pages>
</blog>

And I have the following model objects:

class Blog < ActiveRecord::Base
    has_many :blog_pages

end

class BlogPage < ActiveRecord::Base
    belongs_to :blog

end

Is there a way to convert the xml into a blog object WITH relationships? Or do I need to manually parse the XML?

Thanks in advance.