# If controller is rebuilt each time when we uses redirect\_to?

**URL:** <https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995>\
**Category:** Rails\
**Created:** [December 9, 2005, 3:48pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995 "2005-12-09T15:48:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 3:48pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/1 "2005-12-09T15:48:05Z")

</div>

Hi,

Does anyone know, if a controller is built each time,  
when we use “redirect\_to” ???

Thanks you very much.

Saiho

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 4:37pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/2 "2005-12-09T16:37:11Z")

</div>

Hi !

2005/12/9, Saiho Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Does anyone know, if a controller is built each time,  
> when we use “redirect\_to” ???

What do you mean by ‘rebuilt’ ?

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 5:13pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/3 "2005-12-09T17:13:59Z")

</div>

Hi,

As I understanded (I could be worng), when a request  
is sent to Rails, Rails will create a controller  
object to answer that request, after that the  
controller object will be destroyed by Rails. There is  
no object pool inside of Rails.

if we use “redirect\_to” from page A(controller A) to  
page B (controller B), I think the controller A is  
destroyed, then Rails creates controller B. (Am I  
correct?) I wonder if we redirect page A/f1 to A/f2  
(same controller), is the controller is destroyed and  
then recreate???

Thanks you very much!!!

Saiho

— Francois B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> François Beausoleil  
> [http://blog.teksol.info/](http://blog.teksol.info/)
> 
> > * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 5:54pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/4 "2005-12-09T17:54:43Z")

</div>

redirect\_to from action A to B is no different from if you type in the  
URL for  
action B in your browser and submit it. A new controller instance is  
created  
for every request.

Kent.

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 7:48pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/5 "2005-12-09T19:48:22Z")

</div>

On 12/9/05, Saiho Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Saiho

I wouldn’t worry about it. Chances are if your page is slow, you’re  
pulling too much data from the database or something. If your  
controller is really that big, I’d also consider splitting it up into  
multiple controllers.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 7:44pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/6 "2005-12-09T19:44:10Z")

</div>

Hi,

Thanks you very much for the information, but I wonder  
if each time rails receives a request and recreate an  
instance of controller, is it too heavy? for a simple  
controller, it is quit correct, but if we a “huge”  
one, it may not be the best solution… is there  
someway, we can optimize this…?

thanks you very much

Saiho

— Kent S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > page B (controller B), I think the controller A is
> > 
> > > >
> 
> protection around

If God really exists, I would like to  
know what the dinosaurs have done to  
deserve their extinction.

Water is unknown to fishes,  
until they discover air.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com/)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 10:09pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/7 "2005-12-09T22:09:37Z")

</div>

On 12/9/05, Saiho Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> Thanks you very much for the information, but I wonder  
> if each time rails receives a request and recreate an  
> instance of controller, is it too heavy? for a simple  
> controller, it is quit correct, but if we a “huge”  
> one, it may not be the best solution… is there  
> someway, we can optimize this…?

Hint: Don’t try to optimize anything until you can prove that it’s  
your application’s bottleneck.

---

<div class="post-metadata">

**Author:** ![sayoyo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sayoyo](https://www.ruby-forum.com/u/sayoyo)\
**Post date:** [December 9, 2005, 10:05pm UTC](https://www.ruby-forum.com/t/if-controller-is-rebuilt-each-time-when-we-uses-redirect-to/52995/8 "2005-12-09T22:05:32Z")

</div>

On Dec 9, 2005, at 1:43 PM, Saiho Y. wrote:

> Saiho

Relative to the rest of the processing happening on each request,  
the time it takes to instantiate your controller object would be  
the least of your worries. It’s negligible in the grand scheme  
of things.

Your controllers should not be “huge” anyway.

Are you having some specific performance problems?

–  
Scott B.  
Lunchbox Software  
[http://lunchboxsoftware.com](http://lunchboxsoftware.com)  
[http://lunchroom.lunchboxsoftware.com](http://lunchroom.lunchboxsoftware.com)  
[http://rubyi.st](http://rubyi.st)
