2011-05-19 80 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