require_dependency 'qa'

class ApplicationController < ActionController::Base
  protect_from_forgery

  private

  def current_user
    @current_user ||= User.where('id = ?', session[:user_id]).first if session[:user_id]
  end

  def require_login
    return true if logged_in?
    redirect_to("/login")
  end

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

  def logged_in?
    !!session[:user_id]
  end
  helper_method :logged_in?

  rescue_from QA::NotLoggedIn do |e|
    raise e if Rails.env.test?
    redirect_to '/'
  end
end
require_dependency 'qa'

class ApplicationController < ActionController::Base
  protect_from_forgery

  private

  def current_user
    @current_user ||= User.where('id = ?', session[:user_id]).first if session[:user_id]
  end

  def require_login
    raise QA::NotLoggedIn unless current_user.present?
  end

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

  def logged_in?
    !!session[:user_id]
  end
  helper_method :logged_in?

  rescue_from QA::NotLoggedIn do |e|
    raise e if Rails.env.test?
    redirect_to '/'
  end
end
Rewrite require_login to use QA::NotLoggedIn
Rewrite require_login to use QA::NotLoggedIn
