I need information about the user currently logged in available outside of
controllers. At least in models but probably also in some library code.
I don't want to pass the user object around everywhere. That is ugly and
annoying. So I wanted to make it available somewhere globally to a single
request by some before filter that creates the user object from a user id
stores in session.
Global variables are too global. They are outside the scope of a request.
I have tried the above with Thread.current[:user] for the user object. It
seems to work, but is it a good way? I assume a thread may be used for
several requests so if I am not careful the user object may be passed to
some later request? Should I make a after_filter that assigns nil?
Is there a better way to do this?