>From NKS: "Were you to inspect self in any block, you'd get #<App:0x64eb94>.
So, yeah, all methods run against the Shoes App object.
Instance variables are a good place to store Shoes controls and objects,
since they will be kept in the app and can be yanked at from anywhere
inside the app's scope."
I hope I get this right I'm certainly not a Ruby guru but this is the way I
understand it. Feel free to correct this anyone.
Because you are working within a subclass you don't have access to the
Shoes App object.
Self is Shoes::MyApp within your Subclass. It has access to any Shoes
methods but it can't see the App object.
So since MyApp can't see the Shoes App object @x's scope is limited to
"index".
--Tom
On Thu, Jun 19, 2008 at 10:39 AM, John Wells <[EMAIL PROTECTED]>
wrote:
> Guys,
>
> I've read the NKS cover to cover, but think I might be misunderstanding
> scope.
> For example, in the lastest (git pull; rake) version of shoes, this code:
> #############################
> class MyApp < Shoes
> url "/", :index
> url "/next", :next
>
> def index
> @x = edit_line
> para(link("next", :click=>"/next"))
> end
>
> def next
> begin
> alert (@x.text)
> rescue Exception=>e
> puts e
> end
> end
> end
>
> Shoes::app
> #############################
>
> Outputs "undefined method `text' for nil:NilClass" on the console. So
> @x is nil. However, if I read NKS correctly, especially page 36, @x
> should still exist and the text should be accessible.
>
> Can anyone explain why this is happening?
>
> Thanks,
> John
>