I am trying to find a way to redirect a user when they come back to the site if they are still logged in. I want them to be redirected to their specific home page. I am using rails 3, devise, and cancan.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Devise provides the method
user_signed_in?that you could user to check if the user is already logged in. Then you could usecurrent_userto find the home page for the given user.I would add something like this to the controller that user go through to get to your home page:
Note – This is assuming that your devise model is called User and you have added a method for home_page_path to the user model.