Skip to content

Instantly share code, notes, and snippets.

@boriscy
Created June 10, 2016 14:11
Show Gist options
  • Save boriscy/58949f0c17d609b6e92b9685032d2ae7 to your computer and use it in GitHub Desktop.
Save boriscy/58949f0c17d609b6e92b9685032d2ae7 to your computer and use it in GitHub Desktop.
Stores state user
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