At first I used devise register for one type of user. Works perfectly well, but now I add 2 specifics routes register/users
for lambda users and register/pro
for professional.
Theses two routes uses the same model users, with just changing the form view.
But when I submit the form, in case of failure I am redirect to /users/
and nothing else appends.
To do that, I have done this :
get '/register', to: 'devise/registrations#new', as: :register # original version
# and added :
get '/register/users', to: 'devise/registrations#new', as: :register_users
get '/register/professional', to: 'devise/registrations#new', as: :register_pro
But, like I said, nothing appends but redirect to /users/
if the form is badly filled.
So I also tried to add this :
post '/register/users' => 'devise/registrations#create', :as => :register
post '/register/professional' => 'devise/registrations#create', :as => :register
But same result.
I'm doing something wrong, anybody as an idea?
Thanks !
EDIT :
For now, the problem is that in case of badly fill the formulaire,this redirect to ./users
and not to register/users
. But in case of succeded, it's working.
You need override after_sign_up_path_for
in a Controller(usually ApplicationController)
def after_sign_up_path_for(resource)
if resource.type == :pro # please modify this line
some_your_path
else
super # this will be /users/
end
end
I assume you have User
model. Then this resource
is user object. And I assume you have some attribute in User model to find pro/non-pro. Please use that attribute for 'if' statement and write paths.
If you use Confirmable you need to override after_inactive_sign_up_path_for
instead of after_sign_up_path_for
.
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.