Created
June 10, 2016 14:11
-
-
Save boriscy/58949f0c17d609b6e92b9685032d2ae7 to your computer and use it in GitHub Desktop.
Stores state user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSession | |
class << self | |
attr_reader :user | |
delegate :id, :email, to: :user | |
# Stores using de application_controller the current_user for devise | |
def user=(usr) | |
raise 'You must pass a User class' unless usr.is_a?(User) | |
@user = usr | |
end | |
def user_id | |
user.id | |
end | |
def destroy | |
@user = nil | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment