creddit/app/controllers/application_controller.rb

22 lines
450 B
Ruby
Raw Normal View History

2015-07-08 10:24:41 -04:00
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
2015-07-10 00:19:01 -04:00
helper_method :current_user
helper_method :current_session
helper_method :logged_in?
private
def current_user
@current_user ||= User.find(current_session[:user_id]) if current_session
end
def current_session
@current_session ||= UserSession.authenticate(cookies[:user_session])
end
def logged_in?
!!current_user
end
2015-07-08 10:24:41 -04:00
end