When you add
before_action :authenticate_user!
in any controller the actions of that controller redirect to log in page if you are not signed in, however how to redirect to sign up path instead?
Having
before_action :authenticate_user!
in controller means, you use the inherited method from devise.
To make it perform in any way, that differs from original implementation you have to to override it.
To do so you just define the method in controller and change the behavior to whatever you want.
In your case the closest to your needs would be:
def authenticate_user!
redirect_to(new_user_registration_path, alert: 'Your custom message here') unless user_signed_in?
end