Module: Cally::ApplicationHelper

Included in:
ApplicationController
Defined in:
app/helpers/cally/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject

helper_method :current_user, :logged_in?, :is_admin?, :is_first_user?



5
6
7
# File 'app/helpers/cally/application_helper.rb', line 5

def current_user
  @current_user ||= User.find(session[:user_id]) if session[:user_id]
end

#is_admin?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'app/helpers/cally/application_helper.rb', line 13

def is_admin?
  if logged_in? && current_user.admin
    return true
  else
    return false
  end
end

#is_first_user?(user) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'app/helpers/cally/application_helper.rb', line 21

def is_first_user?(user)
  if user == User.first
    return true
  else
    return false
  end
end

#logged_in?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/helpers/cally/application_helper.rb', line 9

def logged_in?
  !!current_user
end