Skip to content

Instantly share code, notes, and snippets.

@augustf
Created January 19, 2013 03:39
Show Gist options
  • Save augustf/4570639 to your computer and use it in GitHub Desktop.
Save augustf/4570639 to your computer and use it in GitHub Desktop.
In the application controller:
#call on this method to get access to the current user session in models (used in Task model for cocaine)
def set_current_user
User.current = current_user
end
In the User model:
#used to fetch the current user session in models
def self.current
Thread.current[:user]
end
#used to fetch the current user session in models
def self.current=(user)
Thread.current[:user] = user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment