# How do I render a partial view into a string from inside a v

**URL:** <https://www.ruby-forum.com/t/how-do-i-render-a-partial-view-into-a-string-from-inside-a-v/54738>\
**Category:** Rails\
**Created:** [March 13, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/how-do-i-render-a-partial-view-into-a-string-from-inside-a-v/54738 "2006-03-13T21:47:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsaccon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@rsaccon](https://www.ruby-forum.com/u/rsaccon)\
**Post date:** [March 13, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/how-do-i-render-a-partial-view-into-a-string-from-inside-a-v/54738/1 "2006-03-13T21:47:44Z")

</div>

I want to pass the partial to a Javascript function ( which uses the  
data  
for for creating an iframe)

render\_to\_string is not accessible form a view

thanks in advance

---

<div class="post-metadata">

**Author:** ![rsaccon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@rsaccon](https://www.ruby-forum.com/u/rsaccon)\
**Post date:** [March 13, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/how-do-i-render-a-partial-view-into-a-string-from-inside-a-v/54738/2 "2006-03-13T22:09:51Z")

</div>

Call render\_to\_string in the controller and store the result in an  
instance variable. Supply the instance variable to the JS in the view.

or…

use remote\_function to call a method that renders the required template.

\_Kevin

---

<div class="post-metadata">

**Author:** ![rsaccon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@rsaccon](https://www.ruby-forum.com/u/rsaccon)\
**Post date:** [March 13, 2006, 10:24pm UTC](https://www.ruby-forum.com/t/how-do-i-render-a-partial-view-into-a-string-from-inside-a-v/54738/3 "2006-03-13T22:24:06Z")

</div>

Kevin, thanks very much

On 13 Mar 2006 21:07:02 -0000, Kevin O. \<
