# Why is my rxml view being wrapped by the rhtml template in v

**URL:** <https://www.ruby-forum.com/t/why-is-my-rxml-view-being-wrapped-by-the-rhtml-template-in-v/99088>\
**Category:** Rails\
**Created:** [July 20, 2006, 8:16am UTC](https://www.ruby-forum.com/t/why-is-my-rxml-view-being-wrapped-by-the-rhtml-template-in-v/99088 "2006-07-20T08:16:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [July 20, 2006, 8:16am UTC](https://www.ruby-forum.com/t/why-is-my-rxml-view-being-wrapped-by-the-rhtml-template-in-v/99088/1 "2006-07-20T08:16:14Z")

</div>

Why is my rxml view being wrapped by the rhtml template in views/  
layouts?

I was experimenting with REST, I had a nice little test program with  
one table: ‘resources’. Here’s what the show method looks like:

def show  
@resource = Resource.find(params[:id])  
respond\_to do |accepts|  
accepts.html  
accepts.xml  
end  
end

I have a show.rhtml and show.rxml views.

I could see the html doing this:

curl -H ‘Accept: application/xml’ [http://localhost:3000/resource/show/1](http://localhost:3000/resource/show/1)

and the xml doing this:

curl -H ‘Accept: application/xml’ [http://localhost:3000/resource/show/1](http://localhost:3000/resource/show/1)

And it worked … then I must have done something wrong and went to  
dinner. Now I’m back and every request I make asking for xml runs  
layouts/resource.layout. This causes the effect of having my xml  
output wrapped by the html generated by the standard layout template.

Thanks for any ideas!

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [July 20, 2006, 10:53am UTC](https://www.ruby-forum.com/t/why-is-my-rxml-view-being-wrapped-by-the-rhtml-template-in-v/99088/2 "2006-07-20T10:53:58Z")

</div>

need a:

render :layout =\> false

in the controller to stop layout generation

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [July 20, 2006, 1:48pm UTC](https://www.ruby-forum.com/t/why-is-my-rxml-view-being-wrapped-by-the-rhtml-template-in-v/99088/3 "2006-07-20T13:48:39Z")

</div>

On Jul 20, 2006, at 4:53 AM, Brez! !! wrote:

> need a:
> 
> render :layout =\> false
> 
> in the controller to stop layout generation

My controller action looks like this:

def show  
@resource = Resource.find(params[:id])  
respond\_to do |accepts|  
accepts.html  
accepts.xml  
end  
end

It was working just fine without render :layout =\> false – then it  
wasn’t?? Adding your suggestion like this works however:

def show  
@resource = Resource.find(params[:id])  
respond\_to do |accepts|  
accepts.html  
accepts.xml { render :layout =\> false }  
end  
end

I don’t see this needed in any of the examples I read about (example:  
[http://media.pragprog.com/titles/rails2/Rest.pdf](http://media.pragprog.com/titles/rails2/Rest.pdf)) – and now I think  
I must have been hallucinating when I thought it was working  
before …??

Anyways, Thanks for the suggestion!
