My rails application creates XML when loading / reports / generate _report.
On a separate page, I want to read this XML in a variable and store it in a database.
How can i do this? Is there any way to pass the response from / reports / generate _report.xml URI to a variable? Or is there a better way to do this since XML is being created by the same web application?
Here is my generate_report action:
class ReportsController < ApplicationController def generate_report respond_to do |format| @products = Product.all format.xml { render :layout => false } end end end
Here is the action I'm trying to write:
class AnotherController < ApplicationController def archive_current @output =
Solved: My solution (thanks to Mladen Yablanovich):
@output = render_to_string(:file => 'reports/generate_report.xml.builder')
I used the following code in the model class to accomplish the same task, since render_to_string is the (idiotic) protected ActionController :: Base method:
av = ActionView::Base.new(Rails::Configuration.new.view_path) @output = av.render(:file => "reports/generate_report.xml.builder")
source share