In your application controller file app/controllers/application_controller.rb include the following private method:
class ApplicationController < ActionController::Base
# Overwriting the sign_out redirect path method
The return value of this method is the redirect url after sign-out, so you can replace root_path in the method above to set where devise redirects the users after signing out. The method after_sign_out_path_for is overloading the one contained in lib/devise/controllers/helpers.rb within the gem.
Similarly, you can change the default redirect path after sign-in by overriding the after_sign_in_path_for method of devise, like this:
You can change the root_path here with the url of the page you want the users to redirect after successful sign in.