0 Replies - 3003 Views - Last Post: 08 June 2007 - 03:46 PM Rate Topic: -----

#1 spullen  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 10
  • View blog
  • Posts: 356
  • Joined: 22-March 07

xml inside an xml document

Post icon  Posted 08 June 2007 - 03:46 PM

OK, so I have this little problem with creating an xml document.
I am overiding the to_xml method inside a model that I have, and it looks like this:
class Model < ActiveRecord::Base
 #database definitions, and table relationships
 
def to_xml
   xml = Builder::XmlMarkup.new(:indent => 2)
   xml.instruct!
   xml.details do
		xml.tag!(:name,  self.name)# where self calls the data in the column of a database (this works fine), and :name is the name of the column
		xml.tag!(:street, self.street.to_xml) # this is where is gets caught up * (references a table that is foreign to the table of Model, which is another model (obviously))
   end
end
end


*: this is how I was trying to do it, and for the most part it works, except it just takes the xml doc generated and makes it into a string and puts it into the node details, so when I want to parse it, it won't work.

So I guess my question is there a way to insert nodes from another model's table that is joined to the table of the model (set up using belongs_to method)?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1