加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 编辑设计失败的注册路径 – Rails

发布时间:2020-12-17 02:02:23 所属栏目:百科 来源:网络整理
导读:我一直在搜索有关如何在注册失败后编辑注册路径的文档的高低搜索. 我在我的网站索引页面上有我的注册表单.在注册失败时,它会重定向到new_user_registration_path而不是用户所在的root.我该如何更新? 解决方法 我已经能够通过使用customfailure应用程序为注
我一直在搜索有关如何在注册失败后编辑注册路径的文档的高低搜索.

我在我的网站索引页面上有我的注册表单.在注册失败时,它会重定向到new_user_registration_path而不是用户所在的root.我该如何更新?

解决方法

我已经能够通过使用customfailure应用程序为注册表单实现此目的

class CustomFailure < Devise::FailureApp
  def redirect_url
    if warden_options[:scope] == :user
      new_user_registration_path
    else
      new_user_registration_path
    end
  end
  def respond
    if http_auth?
      http_auth
    else
      redirect
    end
  end

  def redirect
    store_location!
    flash[:alert] = i18n_message unless flash[:notice]
    redirect_to '/'
  end
end

当然可以使用类似的选项,这不需要覆盖设计注册控制器吗?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读