# Serving xml

**URL:** <https://www.ruby-forum.com/t/serving-xml/164313>\
**Category:** Rails\
**Created:** [March 31, 2009, 5:16am UTC](https://www.ruby-forum.com/t/serving-xml/164313 "2009-03-31T05:16:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrianunderwater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@adrianunderwater](https://www.ruby-forum.com/u/adrianunderwater)\
**Post date:** [March 31, 2009, 5:16am UTC](https://www.ruby-forum.com/t/serving-xml/164313/1 "2009-03-31T05:16:29Z")

</div>

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

```

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?

Cheers

---

<div class="post-metadata">

**Author:** ![adrianunderwater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@adrianunderwater](https://www.ruby-forum.com/u/adrianunderwater)\
**Post date:** [March 31, 2009, 5:28am UTC](https://www.ruby-forum.com/t/serving-xml/164313/2 "2009-03-31T05:28:29Z")

</div>

Hi Adrian,

On Tue, 2009-03-31 at 05:16 +0200, Adrian Cook wrote:

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

What’s your routes.rb look like?

Bill

---

<div class="post-metadata">

**Author:** ![adrianunderwater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@adrianunderwater](https://www.ruby-forum.com/u/adrianunderwater)\
**Post date:** [March 31, 2009, 5:35am UTC](https://www.ruby-forum.com/t/serving-xml/164313/3 "2009-03-31T05:35:38Z")

</div>

Hi Bill,

bill walton wrote:

> What’s your routes.rb look like?
> 
> Bill

Here it is:  
ActionController::Routing::Routes.draw do |map|  
map.resources :gifts

map.resources :mailing\_list\_users

map.resources :downloads

map.resources :multi\_currency\_prices

map.resources :billing\_infos

map.simple\_captcha ‘/simple\_captcha/:action’, :controller =\>  
‘simple\_captcha’

map.resources :download\_locations

map.resources :drm\_types

map.resources :pages

map.resources :products

map.with\_options :controller =\> ‘products’ do |products|  
map.resources :buy  
end

map.resources :reviews

map.resources :collections

map.namespace(:admin) do |admin|

```
admin.resources :clients, :collection => { :multi_report => :put,
                                            :multi_report_generate 

```

=\> :put }

```
admin.resources :user_groups

admin.resources :discounts

admin.resources :collections

admin.resources :reviews

admin.resources :order_items

admin.resources :coupon_types

admin.resources :product_types

admin.resources :clients

admin.resources :platforms

admin.resources :products

admin.resources :coupons

admin.resources :countries

admin.resources :payments

admin.resources :orders

admin.resources :payment_types

admin.resources :portal_users

admin.resources :billing_infos

admin.resources :exchange_rates

admin.resources :download_locations

admin.resources :drm_types

admin.resources :downloads

admin.resources :article_headers

admin.resources :articles

admin.resources :mailing_list_users

admin.resources :mailing_list_bulletins

admin.resources :mailing_list_groups

admin.resources :pages

```

end

map.root :controller =\> “home”

# Install the default routes as the lowest priority.

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
end

---

<div class="post-metadata">

**Author:** ![adrianunderwater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@adrianunderwater](https://www.ruby-forum.com/u/adrianunderwater)\
**Post date:** [March 31, 2009, 6:13am UTC](https://www.ruby-forum.com/t/serving-xml/164313/4 "2009-03-31T06:13:32Z")

</div>

Hi Adrian,

On Tue, 2009-03-31 at 05:35 +0200, Adrian Cook wrote:

> 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
