2013-03-10 25 views
0

我正在使用Devise進行用戶註冊,並且正在使用Confirmable執行電子郵件驗證。使用Devise +確認後,將用戶重定向到某個頁面

用戶註冊後,我想將它們重定向到一個URL,說明他們需要檢查他們的電子郵件並點擊發送的鏈接。我使用Devise的:authenticate_user!方法來確保用戶在查看網站內容之前登錄。

this file,它看起來像我可以定義一個after_inactive_sign_up_path_for(resource)after_sign_up_path_for(resource)來控制這個重定向。

這裏是我的應用程序控制器:

class ApplicationController < ActionController::Base 
protect_from_forgery 
before_filter :authenticate_user!, :except => [:after_inactive_sign_up_path_for,  :after_sign_up_path_for] 

def after_sign_up_path_for(user) 
    confirm_path 
end 

def after_inactive_sign_up_path_for(user) 
    confirm_path 
end 

end 

但它不工作。 confirm_path是我static_pages控制器,它是沒有登入訪問,因爲我有skip_before_filter :authenticate_user!包括

當用戶登記,在:authenticate_user!助手踢和重定向到登錄頁面。

回答

4

您是否嘗試過重寫登記控制器像這樣:

class RegistrationsController < Devise::RegistrationsController 
    protected 

    def after_inactive_sign_up_path_for(resource) 
    '/an/example/path' 
    end 
end 

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)

+0

感謝!不知道我是如何錯過的。 – Matt 2013-03-10 22:49:05

+0

我也必須重寫after_sign_up_path_for(resource) – 2014-03-13 23:07:19

相關問題