在路徑中,我有指向"home#index"
的根路徑,但是當我嘗試覆蓋與after_sign_up_path_for重新定向我登錄或註冊時根路徑。我試圖把它放在設計的子類控制器和application_controller中,但它不起作用。我需要在這裏做什麼?覆蓋設計after_sign_up_path_for不工作
應用控制器
class ApplicationController < ActionController::Base
protect_from_forgery
def after_sign_up_path_for(resource)
show_cities_path(resource)
end
end
登記控制器
class RegistrationsController < ApplicationController
def after_sign_up_path_for(resource)
show_cities_path(resource)
end
end
路線
root :to => "home#index"
謝謝,這是我的問題。 – MicFin
非常感謝!也有這個問題:D – marman
值得注意的是,這適用於所有情況下,用戶不活躍登錄,例如,如果你重寫'active_for_authentication?'這包括可確認的情況下,用戶不能登錄,直到他們確認他們的帳戶。 –