views:

83

answers:

1

I have an underlying ruby game-engine code and I want to use the web interface to let know the user what's going on and interact with the underlying dynamically created data.

To this effect I want to create a new game variable when a link is press and I want that variable to survive till the user goes out of the page just as a flash object will survive with all its contents till the user goes out of the page.

I can just create the variable in the show action of the controller

  def show
    @game = $site.new_game_of_type(params[:id])
    @game.start
  end

but whenever I make any AJAX update to the page or any other request to the server the variables will disappear so my already started game dies under my feet.

I can not make these variables global as they are created dynamically each time a different user click on the game link.

+2  A: 

You can put the variable in the user's session and it will exist past the request cycle.

Toby Hede