首页 > 解决方案 > 在注册路径后设计一个额外的 reddirect

问题描述

用户注册后,用户登陆after_sign_up_path_for(resource)RegistrationsController

此路径将用户引导至需要显示的屏幕。如果被邀请到群里,用户注册后会登陆群,如果用户被邀请到社区,它会登陆社区等等。重定向路径是通过该store_location_for方法构建的。

我的问题是,在此之前如何进行额外的重定向?

我的目标是有一个 Wellcome 屏幕,然后在按钮处继续重定向到可以是组或社区的提货屏幕。

标签: ruby-on-railsdevise

解决方案


您需要做的就是覆盖after_signup_path_for方法:

def store_location_for
  session[:location] = ...your location
end

def after_signup_path_for(resource_or_scope)
  session[:location].present? ? redirect_to session[:location] : super
end

推荐阅读