# Render doesn't find an html.erb file when called from a xml/atom builder?

**URL:** <https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413>\
**Category:** Rails\
**Created:** [January 18, 2008, 3:20am UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413 "2008-01-18T03:20:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 18, 2008, 3:20am UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413/1 "2008-01-18T03:20:49Z")

</div>

I’m trying to put together an atom feed. In trying to keep things DRY  
it seemed to make sense to render each item in the feed with the same  
html partial that we used to render it on our website. Unfortunately  
render doesn’t seem able to find the template.

More specifically let’s say my controller has an action like this:

def index  
@topics = Datasource.list  
respond\_to do |wants|  
wants.html  
wants.atom do  
render :layout =\> false  
end  
end  
end

And buried inside my index.atom.builder there is a call to render  
shared/topic like so:

entry.content(render( :partial =\> ‘/shared/topic’, :object =\>  
topic ), :type =\> ‘html’)

I was assuming this would find the file at shared/\_topic.html.erb and  
render it appropriately. No luck though, it gives me the error:

Couldn’t find template file for /shared/\_topic in ["/Users/jjb/eng/app/  
views"]

If I specify the full filename for the template (/shared/  
topic.html.erb) it finds it, but that template has nested  
“render :partial” calls without the “.html.erb” on the end so they  
fail with the same error mentioned above.

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 18, 2008, 4:22am UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413/2 "2008-01-18T04:22:15Z")

</div>

Why not just change the file extension to something atom compliant  
(.atom.xml?) What’s in this partial that you want to render?

On Jan 18, 2008 12:49 PM, jeff b [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> respond\_to do |wants|  
> entry.content(render( :partial =\> ‘/shared/topic’, :object =\>  
> “render :partial” calls without the “.html.erb” on the end so they  
> fail with the same error mentioned above.
> 
> Any help would be greatly appreciated.
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 18, 2008, 8:13am UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413/3 "2008-01-18T08:13:32Z")

</div>

The partial I want to render is a .html.erb and is used elsewhere on  
the site for traditional web-browser content. I sort of assumed that  
changing it to .atom.xml might make it work for the atom feed, but  
likewise break for traditional web-browser content for the same  
reason…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 18, 2008, 8:33am UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413/4 "2008-01-18T08:33:29Z")

</div>

sounds like a bug. Have your reported it on Rails Trac?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 18, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413/5 "2008-01-18T21:25:18Z")

</div>

Not yet. I was able to get it to work as expected. In the index  
action changing this:

render :layout =\> false

To this:

render :template =\> ‘topic/index.atom.builder’, :layout =\> false

Seemed to do the trick. Does this sound like a bug?

On Jan 17, 11:33 pm, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 25, 2008, 1:48am UTC](https://www.ruby-forum.com/t/render-doesnt-find-an-html-erb-file-when-called-from-a-xml-atom-builder/126413/6 "2008-01-25T01:48:46Z")

</div>

I found a solution for this - at least in my situation. It seems that  
making the render call from within a respond\_to was causing the  
problem. By moving it to a seperate action and not in respond\_to I  
worked around this strangeness.

On Jan 17, 11:33 pm, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
