ruby-on-rails - 在注册路径后设计一个额外的 reddirect
问题描述
用户注册后,用户登陆after_sign_up_path_for(resource)
。RegistrationsController
此路径将用户引导至需要显示的屏幕。如果被邀请到群里,用户注册后会登陆群,如果用户被邀请到社区,它会登陆社区等等。重定向路径是通过该store_location_for
方法构建的。
我的问题是,在此之前如何进行额外的重定向?
我的目标是有一个 Wellcome 屏幕,然后在按钮处继续重定向到可以是组或社区的提货屏幕。
解决方案
您需要做的就是覆盖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
推荐阅读
- visual-studio - Visual Basics-当 if 语句完成时,它似乎在重复自己并说另一个玩家赢了。这使得其他玩家的生命值减少 30 点
- javascript - 如何在javascript中杀死并重新启动递归函数
- rest - REST API - 设计一个 POST API - 如果它为同一个用户多次调用
- django - django 在这种情况下如何使用Q和过滤related_name?
- c - 来自 C 的指针从内存中删除
- goland - Goland - 从 JSON 模式生成类型定义
- laravel - Laravel 中的驼峰格式表名
- assembly - x86 程序集:当数字末尾包含 0 时,将数字拆分为数字时出现问题
- mysql - 如何在 SQL 联合查询中获得不重复的记录?
- java - 如何使用 vscode 将外部 jar 导入我的项目?