繁体   English   中英

Rails 3:通过Devise注册

[英]Rails 3: sign_up with Devise

我在用dev注册新用户时遇到问题。 在我的索引页面上,我有:

<%= link_to 'New User', new_user_registration_path %>

当我单击链接时,索引页面将重新加载。 如果我单击身份验证页面上的sign_up链接,就没有问题,但是从经过身份验证的用户的索引页面来看,就有问题了。 我在日志中看到:

Redirected to http://localhost:3000

这是屏幕 目标是管理员可以创建新用户。

这是因为您已经登录。

转到此网址: localhost:3000/users/sign_out

然后单击您的链接。

您可以覆盖注册控制器以在注册之前注销。

class Devise::RegistrationsController < ApplicationController
  […]

  # GET /resource/sign_up
  def new
    #OVERWRITE
    sign_out if current_user
    #END

    resource = build_resource({})
    respond_with_navigational(resource){ render_with_scope :new }
  end

  […]
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM