After changing my ssl settings and restarting my Nginx, I started to receive the following error in the Passenger startup:
Before process_action callback :ensure_user_signed_in has not been defined (ArgumentError)
I am running Rails 6, Nginx/Passenger. The protected area is a single namespace only.
sessions_controller
class SessionsController < NamespaceController
skip_before_action :ensure_user_signed_in, only: [:new, :create]
# Present login form
def new
end
# Create Session
def create
user = User.where(email: params[:email]).first
if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to '/namespace/adminhub'
else
redirect_to new_sessions_path, alert: 'Unable to authenticate'
end
end
# Logout
def destroy
reset_session
redirect_to root_path
end
end
Namespace_controller
class NamespaceController < ApplicationController
before_action :ensure_user_signed_in
private
def ensure_user_signed_in
unless current_user.present?
redirect_to new_sessions_path, alert: 'Must be signed in.'
end
end
def current_user
if session.has_key? :user_id
@current_user ||=User.find(session[:user_id])
end
end
helper_method :current_user
end
EDIT: I have attempted to undo my ssl changes in nginx and also to restart passenger, neither seem to be the cause of this issue. Interestingly, when I first pushed out the changes with the Bcrpyt, the page loaded without issue and ran properly, as it does in my development area. It was not until I had to restart the nginx process that this error has come to light.
After a lot more digging and trials, I found this article. In my controller, I added raise: false
to the end of my line.
skip_before_action :ensure_user_signed_in, only: [:new, :create], raise: false
And I was working after that. Although, I am not positive why this worked, it did. I will be continuing my research into this.