我正在使用設計與多個模型進行身份驗證,管理員和用戶。在用戶註冊時,我想重定向到個人資料頁面。 (管理員使用rake任務創建,或通過admin Admin頁面創建,而不是通過註冊過程創建。)設計after_sign_up_path_for不被調用
我使用的是Ruby 2.0.0,Rails 4和Devise 3.1.0。
這是我用來做重定向的代碼,按照StackOverflow和Devise GitHub頁面上的幫助。
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
def after_sign_up_path_for(resource)
Rails.logger.info('ApplicationController: after_sign_up_path_for called')
'/profile'
end
def after_inactive_sign_up_path_for(resource)
Rails.logger.info('ApplicationController: after_inactive_sign_up_path_for called')
'/profile'
end
end
然而,當我通過註冊運行,看來,無論是after_sign_up或after_inactive_sign_up方法被調用,因爲沒有出現記錄。
現在我已經做了一些狩獵,我似乎無法找到我的代碼有任何問題。我想知道是否由於我使用的多模型模型。
任何人都可以對此有所瞭解嗎?
如果您需要查看更多的代碼或其他信息,請詢問。
謝謝。這有幫助。畢竟事實證明我錯過了:controllers => {:registrations =>「registrations」}(在使用了Sunils的建議之後)。乾杯。 –