Here’s a very easy way to change the default render format. Its not necessarily the best way for you. Consider that rendering HTML is hardcoded in the code and it is probably default in the browser/client’s Accept header.
rails/action_pack/lib/action_view/base.rb
when parameter_format.blank? && accept_format != :js
@template_format = :html
For my usage, the best way to change was to add a method to application.rb and call it as a before filter (either by default in application.rb or as needed in each controller)
(updated to a better way)
protected
def set_request_header
xml_string = 'application/xml'
request.instance_eval("@accepts=Mime::Type.lookup('#{xml_string}')")
request.headers['HTTP_ACCEPT'] = xml_string
request.env['HTTP_ACCEPT'] = xml_string
end
it’s not really “playing nice” but it works and is easy to debug and undo
micro theme by seaofclouds, and powered with Mephisto Hosting by hostingrails.com
Leave a Comment