2012-01-16 103 views
2

是否可以只允許現有用戶註冊新用戶?我不希望任何人只要已經登錄就能夠打開/ users/sign_up頁面。這是一個內部應用程序,因此所有用戶都可以信任添加其他用戶。rails設計只允許現有用戶註冊新用戶?

+0

,如果你已經登錄,如果你去'/用戶/ sign_up'你與你是在已簽定的通知重定向。 – 2012-01-16 19:57:46

回答

2

你應該看看cancan寶石!

0

您可以在您的環境中使用http身份驗證。默認情況下使用監獄長

的ApplicationController

before_filter :authenticate_homol 

def authenticate_homol 
    if (Rails.env == 'staging') # for example 
    authenticate_or_request_with_http_basic do |username, password| 
     username == "login" && password == "123456" 
    end 
    warden.custom_failure! if performed? 
    end 
end