Load XML into variable with Rails
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 }
end
end
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 with开发者_StackOverflow社区out rendering it? I don't want use dirty hacks and loading XML from http://appurl/purchases/1.xml
Thanks!
What I was looking for was render_to_string method.
精彩评论