Rails Devise发送邀请后的Invitable重定向 [英] Rails Devise Invitable redirect after send invititaion

查看:208
本文介绍了Rails Devise发送邀请后的Invitable重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了设计的安装和工作。试图找出在他/她发出邀请后如何重定向用户。现在它将我重定向到根目录。我以为你可以按照下面的方法设置你的自定义路径,但是它不起作用。感谢提前,如果有人知道在邀请发送后自定义路径。

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆