Rendering XML from the result of a find

Hi,

I am quite new to Rails.

I have a model, store with
belongs_to :owner

in my controller I have

@store = Store.find(199, :include => :owner)
render :xml @store.to_xml

The result is that the xml only contains the store data, not the owners
data, even though it has retrieved the owners data along with the store.

How can I get the owner data to be included in the XML.

Is it possible to get just specific fields into the XML, such as
owner.name

Thanks

Andrew

You should see this page:

To include owners data: @store.to_xml(:include => “owner”)
To show only specific field, use :only or :except options.

I tried it out with the include. It wasn’t giving me the results I
wanted, so I will try to use Builder Templates and do my own XML.

Using render gives the owner data in a child node under a store. What I
wanted was to have the nodes, such as owner.name at the same level as
the store.

Andrew

I take back what I said, about not having the correct format. I found a
way to access the nested xml values, so I don’t need to use builder.

Andrew