How do I see / change session data from within a thread within rails? See this code snippet inside my controller:
def controller_action
session[:something] = \
I'm still not sure why session would not be in scope by reference inside a thread, but if this is true, you could try passing the current binding to the thread as an argument:
Thread.new(binding) do
thread_session = eval("session", binding)
end
Or something like that. I'm still not convinced that the session is by value and not by reference in the Thread. To check this I just passed some hashes into new threads on the console, and changes made to a hash inside a thread are visible outside that thread. Is there some magic that makes session behave differently?
EDIT: Wouldn't DelayedJob be a better way to handle a long-running process spun off from a user request?