# Why is respond\_to always rending the RXML view?

**URL:** <https://www.ruby-forum.com/t/why-is-respond-to-always-rending-the-rxml-view/135291>\
**Category:** Rails\
**Created:** [April 20, 2008, 8:38pm UTC](https://www.ruby-forum.com/t/why-is-respond-to-always-rending-the-rxml-view/135291 "2008-04-20T20:38:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 20, 2008, 8:38pm UTC](https://www.ruby-forum.com/t/why-is-respond-to-always-rending-the-rxml-view/135291/1 "2008-04-20T20:38:52Z")

</div>

I’m having a problem in Rails 2 where respond\_to is always rendering the  
RXML view even in the HTML rendering response. Can anyone tell me why  
this might be happening? Here’s a code snippet:

respond\_to do |accepts|  
accepts.html  
accepts.xml { render :action =\> ‘show.rxml’, :layout =\> false}  
end

If I change this to the following it works fine:

respond\_to do |accepts|  
accepts.html { render :action =\> ‘show.rhtml’, :layout =\> true }  
accepts.xml { render :action =\> ‘show.rxml’, :layout =\> false }  
end

Here’s my setup:

rails (2.0.2)  
mongrel (1.1.4)  
mongrel\_cluster (1.0.5)  
apache (2.2.6)

Thanks in advance!

- Jason

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [April 20, 2008, 11:36pm UTC](https://www.ruby-forum.com/t/why-is-respond-to-always-rending-the-rxml-view/135291/2 "2008-04-20T23:36:36Z")

</div>

On Sun, Apr 20, 2008 at 2:38 PM, Jason F.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> accepts.html { render :action =\> ‘show.rhtml’, :layout =\> true }  
> accepts.xml { render :action =\> ‘show.rxml’, :layout =\> false }  
> end

The only idea I have is that maybe you don’t need to use render :action.  
Instead, maybe you should be getting some XML from somewhere (such as  
calling #to\_xml on a model or collection) and rendering it like this?

respond\_to do |accepts|  
accepts.html  
accepts.xml { render :xml =\> some\_model.to\_xml }  
end

See also:  
[http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M000211&name=respond\_to](http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M000211&name=respond_to)

Regards,  
Craig
