Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.2 XML rendering using an xml builder

What used to work with Rails 3.1.0 was:

class MyController < ApplicationController
...
    def myAction
      ...
      data = render_to_string( :template => "reports/report.xml.builder", :layout => false)
      ...
    end
end

With Rails 3.2 I am getting a deprecation warning. How do I render an arbitrary xml builder view with Rails 3.2?

like image 722
Mathias Avatar asked Jun 17 '26 23:06

Mathias


1 Answers

Instead of

render(:template => "reports/report.xml.builder", :layout => false)

Rails 3.2 wants

render(:template => “reports/report”, :formats => [:xml], :handlers => :builder, :layout => false)
like image 82
Mathias Avatar answered Jun 20 '26 13:06

Mathias