I have a builder that renders xml when create is called. How can I skip the rendering step, but save the xml to the filesystem?
def create
@server = Server.new(params[:server])
respond_to do |format|
if @server.save
flash[:notice] = "Successfully created server."
format.xml
else
render :action => 'new'
end
end
end
The XML builder can write its data to any object supporting the
<<operator. In your caseStringandFileobjects seem to be the most interesting.Using a string would look something like this:
But since the
Fileclass supports the<<operator as well, you can write the data directly into a file:For further details have a look at the documentation of XmlMarkup.