2014-06-24 116 views
0

在我的註冊表單中,我有一個虛擬布爾參數:register_as_company(複選框)。設計註冊後重定向

我希望將選中框的用戶重定向到「公司/新建」和其他所有人以進行索引。

此頁面有解決方案https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)但我不知道如何將我的參數傳遞給該方法,以便我可以檢查用戶是否選中了該框。

有沒有辦法做到這一點?我應該從哪裏開始?

回答

1

在你RegistrationsController

def after_sign_in_path_for(resource) 
    if params[:user][:register_as_company] 
     new_company_path 
    else 
     stored_location_for(resource) || root_path 
    end 
end