module ActionController class Base def after_sign_out_path_for(resource_or_scope) params[:callback_url] || session[:referrer] || root_path end alias_method :orig_after_sign_in_path_for, :after_sign_in_path_for def after_sign_in_path_for(resource_or_scope) Authentifyd.default_after_sign_in_path || orig_after_sign_in_path_for(resource_or_scope) end end end