application_controller.rb 360 B

123456789101112131415
  1. class ApplicationController < ActionController::Base
  2. protect_from_forgery with: :exception
  3. include SessionsHelper
  4. before_action :logged_in_user
  5. private
  6. def logged_in_user
  7. unless logged_in? || controller_name == 'sessions'
  8. store_location
  9. flash[:danger] = "Please log in."
  10. redirect_to login_path
  11. end
  12. end
  13. end