Sha256: cee0376e89e5a37d9de835dfc022451b85b9913b3a506495bd3aa6c8d7bef29f
Contents?: true
Size: 788 Bytes
Versions: 12
Compression:
Stored size: 788 Bytes
Contents
module Guts # Helpers for sessions # @attr [Object] current_user the current user's object record # @note This is also used by the controllers module SessionsHelper # Set the User's ID to the session # @param [Object] user the user's object record def log_in(user) session[:user_id] = user.id end # Logs the user out by deleting the session def log_out session.delete :user_id @current_user = nil end # Gets the current user's record # @return [Object] the user object def current_user @current_user ||= User.find_by(id: session[:user_id]) end # Determins if the user is logged in # @return [Boolean] true for logged in, false for not def logged_in? !current_user.nil? end end end
Version data entries
12 entries across 12 versions & 1 rubygems