我已遵循此处的指示:
我成功使用自己的注册控制器。这是我的路线代码:
devise_for :users, controllers: {registrations: "users/registrations", sessions: "users/sessions", passwords: "users/passwords", confirmations: "users/confirmations"}
这是我的控制器代码:
class Users::RegistrationsController < Devise::RegistrationsController
def new
super
end
def create
puts "in my custom create action"
super
end
protected
def after_sign_up_path_for(resource)
puts "in after sign up path for"
if resource.new_record? #user not created. Do default behavior: render new user page
puts "new record"
else #user created
puts "user created"
return new_user_session_path
end
end
end
我知道正在调用create动作,因为puts "in my custom create action"
出现在服务器日志中。出于某种原因,未调用after_sign_up_path_for(resource)。我正在使用Devise确认 - 这会有所作为。我该如何解决这个问题?
答案 0 :(得分:0)
是的,confirmable
确实有所作为,因为用户尚未在系统中处于活动状态。您可以在自定义控制器中执行此操作:
def after_inactive_sign_up_path_for resource
# Custom code here
end