Since i'm writing a game in RoR, i need to have a game loop that is responsible for checking different things every time a page refresh happens. My question is, what is the best way to implement ?
I currently include the game_loop in my application controller. Is this the best practice ?
Executing the game look as a
before_filter
in yourApplicationController
sounds reasonable, although you may not wish to put your logic in this class:Do note that this will execute the game loop before every action in your application that involves a controller that extends from
ApplicationController
, including user login, logout, etc. It may be better to add thebefore_filter
only in the controllers that definitely need to process the game loop.