RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: dre-hh
This is not thread-safe at all. Mutating static scope is never threadsafe.
When asking what is thread-safe and what isn't it also depends on your application. In generall mutating shared state without a mutex, semaphore etc. is not threadsafe.
For Rails you have a seperate controller instance per web request thread. So mutating
controller instance vars and all the instance vars of the objects created by controllers is threadsafe, whereby mutating statics is not, because it is shared among all threads.
Rubyists hack around this with the Thread.current Hash