简体   繁体   中英

redirect user to particular page depending on user role after sign_up rails 4

I am developing one job portal using rails 4.0. i have three user roles in my application that is seeker , employer and admin. if user signs up as seeker then he must be redirected to personal details form.

i have written following code inside of my application controller.i have tried this code after searching a lot on web.

def after_sign_up_path_for(user)
  if current_user && current_user.seeker?
  redirect to seeker_infos_path
end

also i tried using registrations controller, but it did not help me.

after_sign_up_path_for doesn't work if confirmable module is active.

If you have confirmable module active, you have to override after_inactive_sign_up_path_for as a new sign-up is "inactive" until it's confirmed.

Note : If you are using your own RegistrationController , you need to put the overriding method in your RegistrationController instead of ApplicationController .

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