serving xml

Hi All,

I'm trying to serve some XML from my Rails 2.0 server.

I have a Flash file that always reads its configuration from /home/gallery.xml

So, I would like to build the contents from the database and serve it back to the flash file when it hits my xml url.

If it was HTML that it was asking for then in my home controller I have a gallery method that serves back a gallery.html.erb but since it wants xml I figured that it would need a gallery.xml.erb and a method like below in my home controller.

  def gallery

    @collection = Collection.find_by_name("banner")

    respond_to do |format|       format.html # gallery.html.erb       format.xml { render :xml => @collection }     end


But, this gives me the routing error: No route matches "/home/gallery.xml" with {:method=>:get}

So, I've tried renaming my gallery.xml.erb to gallery.xml.builder but still no luck. I suspect that it's a problem with my understanding of routing but the html version responds as expected through /home/gallery but not /home/gallery.html.

Any help?


Hi Adrian,

Hi Adrian,

Hi Bill,

bill walton wrote: > > What's your routes.rb look like? > > Bill

Here it is:


  map.connect ':controller/:action/:id.:format'

Thanks. Just wanted to verify you hadn't somehow clobbered the last route.

Take a look at the Accept header of the incoming request (Live HTTP Headers if you don't already have a different preferred tool). My guess is you're not getting a request for xml. Post back if that's not it.

Best regards, Bill