After the create user form is submitted the user is created and then logged in so the page you are being redirected to is actually the after log in page. If you only want to change this page when a user is created you can set session["#{resource_name}_return_to"]
in a custom registration controller like this:
class Users::RegistrationsController < Devise::RegistrationsController
def create
session["#{resource_name}_return_to"] = some_custom_path
super
end
end
You can also create a root route for your user object in routes.rb which will redirect all users whenever they log in:
match "user_root" => "users#home"
Finally you can define the after_sign_in_path_for(resource_or_scope)
method in your application_controller and this will allow you to conditionally redirect users:
def after_sign_in_path_for(resource_or_scope)
if resource_or_scope.is_a?(User)
some_custom_path
else
super
end
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…