diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..1a6caa2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,9 @@ class ApplicationController < ActionController::Base + before_action :authenticate_user + + private + + def authenticate_user + Current.user = User.find_by(id: session[:current_user_id]) + end end diff --git a/app/models/current.rb b/app/models/current.rb new file mode 100644 index 0000000..73a9744 --- /dev/null +++ b/app/models/current.rb @@ -0,0 +1,3 @@ +class Current < ActiveSupport::CurrentAttributes + attribute :user +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fbc9c63..fb838b8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -19,7 +19,11 @@