# Render partial and text in one action

**URL:** <https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542>\
**Category:** Rails\
**Created:** [September 14, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542 "2008-09-14T17:02:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [September 14, 2008, 5:02pm UTC](https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542/1 "2008-09-14T17:02:47Z")

</div>

Hey all,

how can i render :partial and render :text in one action?

I need to update the partial and update an div field with some html  
data.

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [September 14, 2008, 7:32pm UTC](https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542/2 "2008-09-14T19:32:24Z")

</div>

On Sep 14, 11:02 pm, Stephan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hey all,
> 
> how can i render :partial and render :text in one action?
> 
> I need to update the partial and update an div field with some html  
> data.
> 
> ## Thanks for your help 🙂
> 
> Posted viahttp://www.ruby-forum.com/.

How about you use render :update instead?

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [September 14, 2008, 10:21pm UTC](https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542/3 "2008-09-14T22:21:16Z")

</div>

Stephan M. wrote:

> > How about you use render :update instead?
> 
> But how to call the partials?
> 
> render :update |page|
> 
> page.xxxx partials…?
> 
> end

Actually… what you are trying to do doesn’t seem to be possible this  
way. You can only call render ONCE IN A CONTROLLER per request. To clear  
things up a little, what exaclty is your situation?

a) You have a page rendered in the browser and you want to replace a  
part of it with a partial and some other part with a text via ajax?

Then you can use:

render :update do |page|  
page[:name\_of\_part].replace\_html :partial =\> :name\_of\_partial  
page[:name\_of\_other\_part].replace\_html “New Text”  
end

render :update (in this case) sends a javascript back to your browser,  
which updates the elements given by page[:element\_id].

b) You have a normal request and you want to render multiple things from  
your controller?

Not possbile this way. You can call render as many time as you want in a  
view, but only once per action in a controller. So you have to redesign  
this part of your app.

Hope this helps.

Mike

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [September 14, 2008, 7:56pm UTC](https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542/4 "2008-09-14T19:56:00Z")

</div>

> How about you use render :update instead?

But how to call the partials?

render :update |page|

page.xxxx partials…?

end

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [September 15, 2008, 2:19pm UTC](https://www.ruby-forum.com/t/render-partial-and-text-in-one-action/148542/5 "2008-09-15T14:19:14Z")

</div>

I’m not 100% sure what you’re doing, but look at render\_to\_string.

On Sep 14, 4:21 pm, Mike Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
