I have the following code:
def show
@game = $site.new_game_of_type(params[:id])
@game.start
end
def update_game_time
render :partial => 'countdown', :layout => false
end
and the countdown partial:
<div id=countdown> <%= @game.running_time %></div>
In show.html.erb I have:
Time: <div id="countdown"> </div>
<%= periodically_call_remote(:frequency => 0.5,
:update => 'countdown', :url => {:action => :update_game_time}) %>
I want to create a game in the page that is showed by show, so I will have lot of ajax moving there but the user will not click anywhere. All the actions of the controller would be called from Javascript.
I got an error of @game being nil. It is nil even in the method update_game_time how can I make the @game variable to remain valid while the user is in that page?