I am trying to create an API and I need to return xml regardless of the request format. I now have the following in my controller:
def index @posts = Post.all respond_to do |format| format.xml end end
I have index.xml.builder
'/posts.xml' works for me, but not '/ posts'
I tried request.format =: xml, which gave me a SystemStackError (the stack level is too deep) :. Why is this happening.
How to make the controller display xml for all types of requests? so I donโt need to specify a format in the url that looks clean and neat?
source share