# Replace\_html and render action?

**URL:** <https://www.ruby-forum.com/t/replace-html-and-render-action/161476>\
**Category:** Rails\
**Created:** [February 26, 2009, 8:51pm UTC](https://www.ruby-forum.com/t/replace-html-and-render-action/161476 "2009-02-26T20:51:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cojones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9f8e36/32.png) [@cojones](https://www.ruby-forum.com/u/cojones)\
**Post date:** [February 26, 2009, 8:51pm UTC](https://www.ruby-forum.com/t/replace-html-and-render-action/161476/1 "2009-02-26T20:51:02Z")

</div>

Hey,

is it possible to use replace\_html together with a render :action?

This is my code:  
render :update do |page|  
page.replace\_html ‘contentBody’, render(:action =\> ‘new’)  
end

and this is the confusing result in my contentBody:  
try {  
Element.update(“contentBody”, “”);  
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());  
alert(‘Element.update(“contentBody”, “”);’  
); throw e }

Why doesn’t it work? Is there any alternative? It’s a bit tricky  
because:

- I can’t redirect\_to because I need the content in ‘contentBody’
- I can’t render :action cause it wouldn’t know where to put the content  
(coming from a form\_remote\_tag)
- I can’t use partials cause I need to use normal views

Anyone any idea? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![cojones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9f8e36/32.png) [@cojones](https://www.ruby-forum.com/u/cojones)\
**Post date:** [February 27, 2009, 2:38pm UTC](https://www.ruby-forum.com/t/replace-html-and-render-action/161476/2 "2009-02-27T14:38:22Z")

</div>

So from the view where you called this def you might have used  
link\_to\_remote or some thing like that…isn’t it? So add  
:update =\> “contentBody” to that

Now in action just write

render :action =\> ‘new’

Sijo

---

<div class="post-metadata">

**Author:** ![cojones](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9f8e36/32.png) [@cojones](https://www.ruby-forum.com/u/cojones)\
**Post date:** [February 27, 2009, 2:52pm UTC](https://www.ruby-forum.com/t/replace-html-and-render-action/161476/3 "2009-02-27T14:52:47Z")

</div>

Yep, I just figured out that :update was missing right after I posted  
that, thanks 🙂
