Hello,

I had a similar experience with my application, which also used URLs.
The solution I have chosen is to create a static instance `@@model` for
example which contains a reference to some sort of structure or class
that contains your data and any associated operations on said data. 

That instance will not be removed from the class whenever you press
another URL.

Hope that helps.

Cheers,

Marnix

On Mon, 2008-02-11 at 22:17 +0100, Jesús Gabriel y Galán wrote:
> Hi,
> 
> I am starting with Shoes and I have a basic question. It's about the
> scope of variables, and what is self in the methods.
> I've tried searching the net, I've read the 5-6 articles about shoes I
> found but didn't have an answer for this.
> I have this example:
> 
> class Test < Shoes
>       url "/", :index
>       url "/show", :show
> 
>       class << self
>               attr_accessor :b
>       end
> 
>       def index
>               @a = "hello"
>               Test.b =  "goodbye"
>               button "Do" do
>                       visit "/show"
>               end             
>       end
>       
>       def show
>               alert("a is: [EMAIL PROTECTED]")
>               alert("b is: #{Test.b}")
>               alert("self is: #{self}")
>       end     
> end
> 
> Shoes.app :width => 100, :height => 100, :title => "Title"
> 
> The result is that when I click the button the alerts say:
> a is:
> b is: goodbye
> self is: (Test)
> 
> I would have thought that @a would be available through different
> invocations of urls,
> but it seems not. So what is the preferred way of achieving this? I
> have it working
> with class instance variables (Test.b), but I'm not sure if there's a
> better way.
> Also an explanation about which instances of which objects are created would
> probably help me understand what's going on here.
> 
> I have another question about layouts and all that, but I think I'll
> send a separate email later.
> 
> Thanks,
> 
> Jesus.

Reply via email to