How to identify user failure for development in the case of two different user models and an active administrator?

I have two User and ActiveAdmin models on which I want to apply devise integration.

I have my custom_failure.rb as follows

 class CustomFailure < Devise::FailureApp def redirect_url login_path end # def redirect_url # root_path # end def respond if http_auth? http_auth else redirect end end end 

It seems to work fine.

Alternatively, you can define in my application controller as:

 def after_sign_in_path_for(resource) # case resource if resource.is_a?(Admin) admin_dashboard_path else root_path end end 

and

 def after_sign_out_path_for(resource_or_scope) login_path end 

But the problem is how to use this resource in custom_failure.rb so that I can redirect accordingly to login for user login or for admin login ? In the current scenario, it is always redirected to the user login page

+6
source share
1 answer

Try putting custom_failure.rb in the lib folder. Then make sure the file is uploaded. You might be trying to automatically download all the files in lib.

Then redirect to a specific page .

UPDATE:

To solve this problem you should use the area : -

 class CustomFailure < Devise::FailureApp def redirect_url if warden_options[:scope] == :user signin_path else new_admin_user_session_path end end def respond if http_auth? http_auth else redirect end end end 
+11
source

All Articles