render xml

6 views
Skip to first unread message

fugee ohu

unread,
Oct 8, 2018, 1:43:32 PM10/8/18
to Ruby on Rails: Talk
I'm trying to respond xml for any action in my controller but not just by rendering an object I wanna use a view and all the examples I find show how to respond xml with an object like  `respond_with(@asd) # respond_with A` or `  format.xml { render xml: @asd}` 

fugee ohu

unread,
Oct 8, 2018, 1:55:08 PM10/8/18
to Ruby on Rails: Talk


On Monday, October 8, 2018 at 1:43:32 PM UTC-4, fugee ohu wrote:
I'm trying to respond xml for any action in my controller but not just by rendering an object I wanna use a view and all the examples I find show how to respond xml with an object like  `respond_with(@asd) # respond_with A` or `  format.xml { render xml: @asd}` 


 class SitemapController < ApplicationController
  layout :false
  respond_to :xml


  def index
      @host = "#{request.protocol}#{request.host}"
      @people = Person.order("name")
      @pictures = Picture.all
      render
  end

end

fugee ohu

unread,
Oct 8, 2018, 1:58:21 PM10/8/18
to Ruby on Rails: Talk


On Monday, October 8, 2018 at 1:43:32 PM UTC-4, fugee ohu wrote:
I'm trying to respond xml for any action in my controller but not just by rendering an object I wanna use a view and all the examples I find show how to respond xml with an object like  `respond_with(@asd) # respond_with A` or `  format.xml { render xml: @asd}` 


Since google says my sitemap.xml is unknown type it must be I'm rendering xml but not seending an xml content/type header first So how do I send the header?
Reply all
Reply to author
Forward
0 new messages