Take the 2-minute tour ×

This is how I generate XML for purchase model:

# GET /purchases/1
def show
  @purchase = Purchase.find(params[:id])
  @purchases = Purchase.all

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :action => "something.xml.builder", :layout => false }

Now I'd like to get this rendered XML as string into variable so I could post it to WebService.

How can I get XML through sales_invoice.xml.builder without rendering it? I don't want use dirty hacks and loading XML from http://appurl/purchases/1.xml


share|improve this question

1 Answer 1

up vote 0 down vote accepted

What I was looking for was render_to_string method.

share|improve this answer

Your Answer


