Marcelo
Unfortunately like you mentioned when you use the :only options it
will filter through all the associations as well. You can get around
this by passing a proc to_xml that appends the associations to the
builder. For example we will take the ever so popular example of a
User having many Posts.
class User
has_many :posts
end
class Post
belongs_to :user
end
user = User.first
posts = user.posts
post_proc = lambda do |options|
options[:builder] << posts.to_xml(:skip_instruct => true)
end
user.to_xml(:only => :first_name, :procs => post_proc)
Make sure you have the :skip_instruct => true option when you are
creating the xml for your associations so it does not add the XML
declaration <?xml version="1.0 ... >
Cheers.
--
Robert Zotter
Zapient, LLC
Ruby on Rails Development and Consulting
http://www.zapient.com
http://www.fromjavatoruby.com