orginially posted by @thatmoodyguy on Exploring Ruby

If you’re using the Devise gem to handle authentication duties for your application, you going to need a way to
determine what happens after the user signs in, signs up, or signs out of your application. Devise provides a means to
do this with the after_sign_in_path_for, after_sign_up_path_for, and after_sign_out_path_for methods. Simply override
these methods with your own methods of the same name in your ApplicationController, and you’re all set.

Except there’s a catch. Overriding after_sign_in_path_for and after_sign_out_path_for in ApplicationController will
work, but if you override after_sign_up_path_for, it won’t work. It turns out that you need to override the
RegistrationsController class, and override the method inside that controller. Your new controller will look something
like this:

  
class RegistrationsController < Devise::RegistrationsController  
	def create    
		super  
	end  
  
	protected  

	def after_sign_up_path_for(resource)    
		if resource.is_a?(User) && resource.account&.needs_subscription?
			new_subscription_path    
		else      
			root_path    
		end  
	end
end