# How do I call a controller from a model, console, or outside

**URL:** <https://www.ruby-forum.com/t/how-do-i-call-a-controller-from-a-model-console-or-outside/100753>\
**Category:** Rails\
**Created:** [July 31, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/how-do-i-call-a-controller-from-a-model-console-or-outside/100753 "2006-07-31T22:11:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@Jason\_E](https://www.ruby-forum.com/u/Jason_E)\
**Post date:** [July 31, 2006, 10:11pm UTC](https://www.ruby-forum.com/t/how-do-i-call-a-controller-from-a-model-console-or-outside/100753/1 "2006-07-31T22:11:34Z")

</div>

Hi,

I’m writing yet another cms and I need to capture the html output of a  
rendered template including helpers, etc from within my rails app. I  
plan to use backgroundrb, and I need to be able to capture the output of  
“pages.browse()” where pages is my controller. I need to pass in the id  
param.

How can I do this besides using Net::HTTP? Using Net::HTTP hangs when  
I’m testing using webrick.

I see that Actioncontroller::IntegrationTest can do this, but I have no  
idea of how to call that from a development/production environment.

Thanks,  
Jason

---

<div class="post-metadata">

**Author:** ![Jason\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@Jason\_E](https://www.ruby-forum.com/u/Jason_E)\
**Post date:** [August 1, 2006, 12:17am UTC](https://www.ruby-forum.com/t/how-do-i-call-a-controller-from-a-model-console-or-outside/100753/2 "2006-08-01T00:17:27Z")

</div>

On Jul 31, 2006, at 1:08 PM, Jason E. wrote:

> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)  
> Hey Jason-

```
I think you can just use render_to_string to capture what you want.

```

-Ezra
