Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module CurrentUser
def signed_in?
!current_user.nil?
end
def sign_in(user)
self.current_user, session["user_id"] = user, user.id
end
def sign_out
self.current_user = session["user_id"] = nil
end
def current_user=(user)
@current_user = user
end
def current_user
@current_user || User.find(session["user_id"]) if session["user_id"] || nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.