# Does respond\_to play nicely with render :update?

**URL:** <https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890>\
**Category:** Rails\
**Created:** [April 19, 2009, 3:01am UTC](https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890 "2009-04-19T03:01:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 19, 2009, 3:01am UTC](https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890/1 "2009-04-19T03:01:29Z")

</div>

I have a custom format that I’m using called ‘desktop’.

I have an action which is called via AJAX, and I’d like to update a div  
in my page with a partial.

The request comes in with params[:format] == ‘desktop’, and my partial  
is named \_search\_results.desktop.erb

However, when I do this in my action:

respond\_to do |format|  
format.desktop {render :update do |page|  
page.replace\_html(‘search\_results’, :partial =\>  
‘search\_results’)  
end}  
end

I keep getting errors about missing \_search\_results.html.erb.

Can you not use a custom format with the render :update do |page| idiom?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 19, 2009, 5:12am UTC](https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890/2 "2009-04-19T05:12:03Z")

</div>

I think I remember an issue that when using custom formats you need to  
give the full path the the partial like :partial =\> ‘posts/  
search\_results’.

Bradly Feeley

On Apr 18, 6:01 pm, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 19, 2009, 5:19am UTC](https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890/3 "2009-04-19T05:19:56Z")

</div>

Bradly Feeley wrote:

> I think I remember an issue that when using custom formats you need to  
> give the full path the the partial like :partial =\> ‘posts/  
> search\_results’.
> 
> Bradly Feeley
> 
> On Apr 18, 6:01ï¿½pm, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

That doesn’t seem to work for me.

W

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 21, 2009, 3:13pm UTC](https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890/4 "2009-04-21T15:13:39Z")

</div>

Try to include the extension – :partial =\> ‘posts/  
search\_results.desktop.erb’.

Dmitry

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 21, 2009, 3:48pm UTC](https://www.ruby-forum.com/t/does-respond-to-play-nicely-with-render-update/165890/5 "2009-04-21T15:48:00Z")

</div>

If I do this, it works:

page.replace\_html(‘search\_results’, render(:partial =\>  
‘search\_results’))

Notice that originally, I was passing just the hash key/value pair, but  
now I am passing a render call.

According to the API docs:

“options\_for\_render may be either a string of HTML to insert, or a hash  
of options to be passed to ActionView::Base#render.”

which is what I was doing that wasn’t working. I wonder if what happens  
when I pass the render call, is that returns a string that is used in  
the replace\_html call.

Thanks,  
Wes
