title: Saving XML files with Rails
body: <p>im working on a Rails project that should create XMl files, or to be more specific
  use existing XMl templates and put content from the database in it.</p>
  
  <p>So i dont need to create the xml structure, basically just rendering a template with content.
  What would be the smartest way to do that?</p>
  
  <p>So far i have a file.xml.erb in my layout folder
  and i have a custom route "/renderXML" that does</p>
  
  <pre><code>def renderXML 
    @reading_question = ReadingQuestion.find(params[:id])
    render :file =&gt; 'layouts/question.xml'
  end
  </code></pre>
  
  <p>This works, but i also want to save the file, not only show it (actually viewing it is not really needed).
  For saving i found this </p>
  
  <pre><code>File.open('fixed.xml','w'){|f| f.write builder.to_xml}
  </code></pre>
  
  <p>How do i access the rendered file and save it with some method like above?</p>