# How does view know about instance vars set in controller?

**URL:** <https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587>\
**Category:** Rails\
**Created:** [March 22, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587 "2009-03-22T19:31:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 22, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587/1 "2009-03-22T19:31:32Z")

</div>

Hi,

I know that the AWDWR says to believe in magic and to not spend Xmas  
with people asking this question, but really how does it work under the  
hood?

I was looking at the source code of crummy, and it seems that  
instance\_variable\_set and instance\_variable\_get may be part of the  
answer. Is there some resource on that or do I have to dive into Rails  
code?

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 22, 2009, 8:39pm UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587/2 "2009-03-22T20:39:17Z")

</div>

On Mar 22, 6:31 pm, Fernando P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,
> 
> I know that the AWDWR says to believe in magic and to not spend Xmas  
> with people asking this question, but really how does it work under the  
> hood?
> 
> I was looking at the source code of crummy, and it seems that  
> instance\_variable\_set and instance\_variable\_get may be part of the  
> answer. Is there some resource on that or do I have to dive into Rails  
> code?

The method you’re interested in is \_copy\_ivars\_from\_controller in  
ActionView::Base

Fred

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 24, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587/3 "2009-03-24T19:06:39Z")

</div>

On Tue, Mar 24, 2009 at 11:49 AM, Fernando P.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there  
> somewhere a documentation that could walk me through the Rails’ source  
> code from the entry point (let’s say Rack) to the response (returned by  
> Rack to the client)?

To what end?

> Following it by hand is a bit tedious, I often lose myself in method  
> calls that call 3 other methods that call 4 other methods.

Use the “step” command in the debugger.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 24, 2009, 9:06pm UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587/4 "2009-03-24T21:06:41Z")

</div>

> To what end?  
> [200, {‘Content-type’ =\> ‘text/html’}, response]

😃

> Use the “step” command in the debugger.  
> Any experience with Unroller? It seems to do what I want. I’ll give a  
> try at the step command too.

Thanks,

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 24, 2009, 5:49pm UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587/5 "2009-03-24T17:49:11Z")

</div>

> The method you’re interested in is \_copy\_ivars\_from\_controller in  
> ActionView::Base
> 
> Fred

Thank you very much Fred. But how can I find about that myself? Is there  
somewhere a documentation that could walk me through the Rails’ source  
code from the entry point (let’s say Rack) to the response (returned by  
Rack to the client)?

Following it by hand is a bit tedious, I often lose myself in method  
calls that call 3 other methods that call 4 other methods.

---

<div class="post-metadata">

**Author:** ![fipa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9e8a1a/32.png) [@fipa](https://www.ruby-forum.com/u/fipa)\
**Post date:** [March 25, 2009, 9:03am UTC](https://www.ruby-forum.com/t/how-does-view-know-about-instance-vars-set-in-controller/163587/6 "2009-03-25T09:03:28Z")

</div>

> > Use the “step” command in the debugger.  
> > Any experience with Unroller? It seems to do what I want. I’ll give a  
> > try at the step command too.  
> > In put require ‘rubygems’, ‘ruby-debug’ and then debugger right in  
> > script/server, and man there is a lot of stuff to learn.

s[tep] is exactly what I was looking for, up to now I was only using  
n[ext] which didn’t do enough for me.

Thanks for the tip 😉
