Module: SessionsHelper

Included in:
ApplicationController
Defined in:
app/helpers/sessions_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject


10
11
12
# File 'app/helpers/sessions_helper.rb', line 10

def current_user
  User.find_by_id(session[:user_id])
end

#log_in(user) ⇒ Object


2
3
4
# File 'app/helpers/sessions_helper.rb', line 2

def (user)
  session[:user_id] = user.id
end

#log_outObject


6
7
8
# File 'app/helpers/sessions_helper.rb', line 6

def log_out
  session[:user_id] = nil
end

#logged_in?Boolean

Returns:

  • (Boolean)

14
15
16
# File 'app/helpers/sessions_helper.rb', line 14

def logged_in?
  !!current_user
end