# How to render an action in page.replace\_html?

**URL:** <https://www.ruby-forum.com/t/how-to-render-an-action-in-page-replace-html/131789>\
**Category:** Rails\
**Created:** [March 13, 2008, 8:28am UTC](https://www.ruby-forum.com/t/how-to-render-an-action-in-page-replace-html/131789 "2008-03-13T08:28:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 13, 2008, 8:28am UTC](https://www.ruby-forum.com/t/how-to-render-an-action-in-page-replace-html/131789/1 "2008-03-13T08:28:10Z")

</div>

Hi all…

I have an action show\_primary\_contacts\_edit in ci controller, that  
renders  
html. I have another action show\_contacts\_page in ci controller, that  
returns RJS.

I want to replace a div “contacts\_div” specified in  
show\_primary\_contacts\_edit.rhtml with the action  
show\_primary\_contacts\_edit. I wrote the code for this in  
show\_contact\_page.rjs as:

page.replace\_html “contacts\_div”, render(:action =\>  
‘show\_primary\_contacts\_edit’), :object =\> @contacts

The div is replaced. But no contents are displayed. I think the render  
action in page.replace\_html is not working.

How can i replace the html by the contents in an action?

Anybody please help me to solve this.

Thanks in advance  
Suneeta

---

<div class="post-metadata">

**Author:** ![suneeta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@suneeta](https://www.ruby-forum.com/u/suneeta)\
**Post date:** [March 13, 2008, 12:33pm UTC](https://www.ruby-forum.com/t/how-to-render-an-action-in-page-replace-html/131789/2 "2008-03-13T12:33:31Z")

</div>

Suneeta Km wrote:

> Hi all…
> 
> I have an action show\_primary\_contacts\_edit in ci controller, that  
> renders  
> html. I have another action show\_contacts\_page in ci controller, that  
> returns RJS.

The action should render an rhtml page which renders a partial.

> I want to replace a div “contacts\_div” specified in  
> show\_primary\_contacts\_edit.rhtml with the action  
> show\_primary\_contacts\_edit. I wrote the code for this in  
> show\_contact\_page.rjs as:
> 
> page.replace\_html “contacts\_div”, render(:action =\>  
> ‘show\_primary\_contacts\_edit’), :object =\> @contacts

I don’t know what the benefit of an .rjs is as a separate file. Just  
write this  
into the action that responds to show\_contacts - I’m guessing Ajax calls  
that  
action:

render :partial =\> ‘show\_contacts’, :locals =\> { :@contacts =\>  
@contacts }

That calls a partial named \_show\_contacts.rhtml.

–  
Phlip  
[http://assertxpath.rubyforge.org/](http://assertxpath.rubyforge.org/)
