Ruby Singleton and Shotgun

943 Views Asked by At

Im starting with Ruby and our team leader sends us to learn Sinatra, reloading the application changes is been done by Shotgun, my problem now is that i have a Singleton entity which i would love to keep states between request, but aparently Shotgun restarts is every request.

Any Help or Explanation on this would be apreciated,

Thanks in advance.

2

There are 2 best solutions below

0
On

For sessions to persist with Shotgun you need to set the key... Otherwise it is reset with every page load.

enable :sessions
set :session_secret, "yourKey" 
3
On

You shouldn't expect anything about your application's state to be saved between requests at all (Shotgun or not) unless it is being saved in session data.