diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 543296f..ea6fab9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,4 +5,13 @@ class ApplicationController < ActionController::Base def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end + + private + + def require_login + unless current_user + flash[:error] = 'You must be logged in to access this page' + redirect_to root_path + end + end end