Forum: Ruby on Rails How does view know about instance vars set in controller?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-03-22 19:31
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?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-22 20:39
(Received via mailing list)
On Mar 22, 6:31 pm, Fernando Perez <rails-mailing-l...@andreas-s.net>
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
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-03-24 17:49
> 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.
Aad37b5f7116c8d1f547d23b37566032?d=identicon&s=25 Greg Donald (destiney)
on 2009-03-24 19:06
(Received via mailing list)
On Tue, Mar 24, 2009 at 11:49 AM, Fernando Perez
<rails-mailing-list@andreas-s.net> 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 Donald
http://destiney.com/
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-03-24 21:06
> To what end?
[200, {'Content-type' => 'text/html'}, response]

:-D


> 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,
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2009-03-25 09:03
>> 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 ;-)
This topic is locked and can not be replied to.