Output XML to File

I am trying to read some information based on a user id, then search the
database for the needed info and build an XML file. Everything seems to
be working fine; I read the info, I create the xml and even spit “stuff”
out to file. The issue is that the “stuff” I am writing to a file is a
xml/html cross cluster #@%$ of stuff. Here is some code:

if !params[:id].blank?
@user = User.find_by_id(params[:id])

@xml = ::Builder::XmlMarkup.new
@unusedtickets = Unusedticket.find(:all, :conditions => ['user_id =

? and
updated = true’, @user.id])

for unusedticket in @unusedtickets
@xml.unusedtickets do

headers[“Content-Type”] ||= ‘text/xml’
headers[‘Cache-Control’] = ‘private’
headers[“Content-Disposition”] ||= “attachment; filename=“test_xml””
render :text => @xml, :layout => nil

I really thought that if I said :layout => nil that would strip away all
the html formatting, but apperantly not. Is there a way that I can write
this information to a file and have it be strictly XML? Thanks,


How about:

puts User.find_by_id(params[:id]).to_xml

On Aug 4, 5:42 pm, Shandy N. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs