简体   繁体   中英

Redirect after devise sign up

In my sign up form I have a virtual bool parameter :register_as_company (checkbox).

I want users who checked the box to be redirected to 'companies/new' and everyone else to index.

This page has a solution https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration) but I don't know how to pass my parameter to that method so I can check if the user checked the box or not.

Is there a way to do this? Where should I start?

In your 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM