我正在使用 Devise Invitable,我在 SO(这里是一个)上找到了一些答案,说我应该after_invite_path_for(resource)
在我的Users::InvitationsController < DeviseController
.
我试过了,它仍然不起作用。
这是我的控制器:
class Users::InvitationsController < Devise::InvitationsController
def after_invite_path_for(resource)
root_path
end
def create
@member ||= Member.find_or_create_by(email: params[:user][:email], first_name: get_first_name(params[:user][:full_name]), last_name: get_last_name(params[:user][:full_name]), bio: params[:user][:bio], gender: params[:user][:gender])
@membership ||= Membership.find_or_create_by(member: @member, family_tree: current_user.family_tree, inviter: current_user, relation: params[:user][:invitation_relation])
if @user_exists ||= invited_user_exists(params[:email])
else
super
end
end
end
当我尝试在块中添加一个redirect_to root_path
右侧...时,它会引发有关重定向的错误已被调用。super
else
我相信这是真的,因为如果您在此处检查创建操作的来源,您将看到重定向。
这是服务器日志:
Started POST "/users/invitation" for 127.0.0.1 at 2015-12-02 03:58:57 -0500
Processing by Users::InvitationsController#create as HTML
Rendered users/mailer/invitation_instructions.html.erb within layouts/mail (1.2ms)
# truncated for brevity
Rendered users/invitations/create.html.erb within layouts/devise (0.6ms)
Rendered shared/_navbar.html.erb (1424.4ms)
Completed 200 OK in 9221ms (Views: 4732.1ms | ActiveRecord: 102.0ms)
请注意,它永远不会重定向到任何地方。