# From within a View, how can I render the text output from a separate controller action?

**URL:** <https://www.ruby-forum.com/t/from-within-a-view-how-can-i-render-the-text-output-from-a-separate-controller-action/154989>\
**Category:** Rails\
**Created:** [December 5, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/from-within-a-view-how-can-i-render-the-text-output-from-a-separate-controller-action/154989 "2008-12-05T22:15:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 5, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/from-within-a-view-how-can-i-render-the-text-output-from-a-separate-controller-action/154989/1 "2008-12-05T22:15:56Z")

</div>

Hi,

Question = From within a View, how can I render the text output from a  
separate controller action??? (call it graph/get\_data)

So it’s not a partial, as what I want to do is make a separate call to  
get the data to display.

Background = I have a two step process for an ad-hoc report. The  
first step is to gather the options, then the second action/view is to  
display. The thing is in the display view the graph is actually an  
embedded Flash object and it gets it’s data via the URL of my  
graph/get\_data controller/action. To pass the options from the  
collect to display steps I used Flash however. So the side effect is  
that I can’t just navigate to the graph/get\_data URL and see the XML  
data anymore, as it relies upon the flash object being there for all  
the details of the graph. To aid in bug finding I’m just after a way  
(when I’m attempting to display the graph) to see the output from the  
graph/get\_data controller/action, which is XML using the Rails builder  
views.

Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 7, 2008, 3:25am UTC](https://www.ruby-forum.com/t/from-within-a-view-how-can-i-render-the-text-output-from-a-separate-controller-action/154989/2 "2008-12-07T03:25:41Z")

</div>

bump - still interested if anyone knows

On 12/5/08, Greg H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> display. The thing is in the display view the graph is actually an  
> Thanks

–  
Sent from my mobile device

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 7, 2008, 4:34am UTC](https://www.ruby-forum.com/t/from-within-a-view-how-can-i-render-the-text-output-from-a-separate-controller-action/154989/3 "2008-12-07T04:34:41Z")

</div>

I don’t know if this is what you are after, but it would make sense  
that you could do something like this:

def action\_that\_renders\_lots\_of\_stuff  
separate\_action  
render :action =\> separate\_action  
end

def separate\_action

# set a bunch of instance variables

end

Also consider render\_to\_string as a way to capture the output to do  
with as you please later.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [December 7, 2008, 5:47am UTC](https://www.ruby-forum.com/t/from-within-a-view-how-can-i-render-the-text-output-from-a-separate-controller-action/154989/4 "2008-12-07T05:47:44Z")

</div>

Once you decide on an HTML element to hold the results from the  
controller action, you can do simple things like a “remote\_function”  
to update it. You can render a partial into a div as well, so don’t  
bother trying to generate HTML tags in your controller.

On Dec 6, 2:13 am, “Greg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
