2014-06-24 100 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