I've seen threads like this on thread-safety in Rails and various web pages on the topic, and I'm sure everyone's great at reciting what it is and giving 'tips' on what isn't thread-safe ("class variables!"), but I can never seem to find a clear, simple, complete example of something that is actually not thread-safe in Rails, to the point where I wonder if anyone actually understands it at all.
I would be grateful if someone could prove me wrong and give:
a clear, simple, complete example of something that is not thread-safe in Rails. It should be clear where the code is (i.e., if it is in the controller, please show it as such) and nothing should be left to the reader's imagination (such as a method that doesn't exist). Also, there shouldn't be any superfluous code or logic.
exactly how it would be problematic in the context of two users connecting to the website at the same time, on two different threads.
how to rectify the problem.
The more significant and Rails-relevant the example, the better, so if you can give an example where one user might see another user's data (or similar), please do so.