How can I configure my Rails app such that after the form to create a new user is submitted (through devise), I redirect to my own desired page ?
Thank you
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.
After the create user form is submitted the user is created and then logged in so the page you are being redirected to is actually the after log in page. If you only want to change this page when a user is created you can set
session["#{resource_name}_return_to"]in a custom registration controller like this:You can also create a root route for your user object in routes.rb which will redirect all users whenever they log in:
Finally you can define the
after_sign_in_path_for(resource_or_scope)method in your application_controller and this will allow you to conditionally redirect users: