Rails Devise发送邀请后的Invitable重定向 [英] Rails Devise Invitable redirect after send invititaion
问题描述
def after_invite_path_for(资源)
new_profile_path
end
我偶然发现你的问题,因为我有同样的问题。只要我可以告诉你想要的方式来覆盖after_invite_path_for是覆盖Devise :: InvitationsController。
class Users :: InvitationsController< Devise :: InvitationsController
def after_invite_path_for(资源)
new_profile_path
end
end
routes.rb
devise_for:users,:controllers => {:invitations => users / invitations}
如果devise invitable正常工作,你可以覆盖其在应用程序控制器中的邀请/接受路径之后。我修改了devise_invitable工作,并提交了一个拉请求。我不确定是否接受,但您可以在这里查看: https: //github.com/scambra/devise_invitable/pull/240 。
如果该功能被接受,您可以修改当前版本的可邀请的尊重定义在应用程序控制器中的邀请/接受路径之后,将其放在初始化程序中:
#make invitable的路径功能在应用程序控制器中可覆盖
[:after_invite_path_for,:after_accept_path_for] .each do | method |
Devise :: InvitationsController.send(:remove_method,method)如果ApplicationController.method_defined?方法
end
I got the devise invitable installed and working. Trying to figure out how to redirect the user after he/she sent an invitation out. Right now it's redirecting me to the root. I thought you can just set your custom path in the method below but it didn't work. Thanks in advance if anyone know where to customize the path after invite sent.
def after_invite_path_for(resource)
new_profile_path
end
I stumbled upon your question because I was having the same issue. As far as I can tell the intended way for you to override after_invite_path_for is to override Devise::InvitationsController.
class Users::InvitationsController < Devise::InvitationsController
def after_invite_path_for(resource)
new_profile_path
end
end
routes.rb
devise_for :users, :controllers => { :invitations => "users/invitations" }
It would be nice if devise invitable worked like devise proper and you could override its after invite/accept paths in application controller. I modified devise_invitable to work that way and submitted a pull request. I'm not sure if it will be accepted or not, but you can have a look here: https://github.com/scambra/devise_invitable/pull/240.
If that feature is accepted, you could patch your current version of invitable to respect definitions of after invite/accept paths in application controller by putting this in an initializer:
#make invitable's path functions overridable in application controller
[:after_invite_path_for, :after_accept_path_for].each do |method|
Devise::InvitationsController.send(:remove_method, method) if ApplicationController.method_defined? method
end
这篇关于Rails Devise发送邀请后的Invitable重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!