gpt4 book ai didi

ruby-on-rails - Rails 设计 : How to access sign up page after signed in?

转载 作者:行者123 更新时间:2023-12-05 00:05:23 28 4
gpt4 key购买 nike

我是 Rails 的新手,我正在使用“设计”gem 进行身份验证。

首先,我通过默认注册页面(例如/users/sign_up)添加一个新用户

然后,我按照从

Devise before filter that prevents access to "new_user_registration_path" unless user is signed-in

现在,在登录过程后,当我尝试打开注册页面时,它总是将我定向到 root_path!我如何访问注册页面?
我的“roots.rb”文件如下:

Example::Application.routes.draw do

devise_for :users, :controllers => { :registrations => 'registrations'}

resources :companies

resources :orders

resources :customers

root :to => "welcome#index"

end

谢谢你们!

最佳答案

我还有其他决定。比特佐特说

As you can see in the devise source if you navigate to the sign_up it executes the before_filter require_no_authentication and this redirects to the root path which you can find here.



您不需要覆盖registration_controller,您只能更改与原始registration_controller 相呼应的自定义registration_controller。
class Admin::RegistrationsController < Devise::RegistrationsController
layout 'admin'
prepend_before_filter :require_no_authentication, :only => []
prepend_before_filter :authenticate_scope!
end

关于ruby-on-rails - Rails 设计 : How to access sign up page after signed in?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4545166/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com