2011-05-19 55 views
-1

我有一个用devise注册新用户的问题。在我的索引页上,我有这个:Rails 3:与设计的sign_up

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

当我点击链接时,索引页面会重新加载。如果我在验证页面上点击sign_up链接,没有任何问题,但是从验证用户的索引页面出现问题。我在日志中看到:

Redirected to http://localhost:3000 

这是screen。目标是管理员可以创建一个新用户。

+1

您应该接受答案。 – 2011-05-20 03:02:50

+0

[Rails 3:Problem with Devise]的可能重复(http://stackoverflow.com/questions/6061552/rails-3-problem-with-devise) – sawa 2011-05-20 10:00:01

回答

1

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

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 
1

这是因为您已经登录

到这个网址:localhost:3000/users/sign_out

然后点击你的链接。

+0

感谢您的回复。我认为是这样,但是有任何解决方案可以从记录的帐户创建新用户? – 2011-05-19 17:59:15

+0

不,你不能,这是Devise团队最新推动的一个。你应该看看这个:[设计提交](https://github.com/plataformatec/devise/commit/4fd866d113d2de94371afe4798f242c1a453c1ab) - 说明:如果用户已经通过cookie登录,用户将无法访问注册和类似页面,或者令牌,关闭#1036。 – Lucas 2011-05-19 18:10:14

+0

好的谢谢你的回复,祝你有美好的一天 – 2011-05-19 18:13:57