-1

I have rails app that uses Devise with confirmable by email. Emails are send thru gmail. When user fill registration form then is redirected to "/user", but this path doesn't exists hence app crashes. Is there anything that I can do, to force redirect after submit to index? Yes I've already tried Devise Wiki thanks

Skodik.o
  • 506
  • 4
  • 21

1 Answers1

3

Before you ask such questions please take some time and search for the solution by yourself.

It took me 30 seconds to find the Solution on a Wiki page of Devise.

Just create a RegistrationsController which inherits from Devise::RegistrationsController and add a #after_sign_up_path_for method to it.

Then just add devise_for :users, controllers: { registrations: "registrations" } to your routes if you have users as resource.

Tobias
  • 4,523
  • 2
  • 20
  • 40
  • If everyone who could research did so, 90% of folks would be out of jobs :) Sometimes it's the convenience / assurance people need – Richard Peck Jan 10 '16 at 11:51
  • `@Skodik.o` can you explain what results you've seen? You mention it didn't work; what happened? – Richard Peck Jan 10 '16 at 11:52
  • I have registrations_controller.rb with defined method for after_sign_up_path_for and even method for after_inactive_sign_up_path_for, both should return index - 'posts#index'. When user finishes registration then instead of redirecting to index it redirects to /users – Skodik.o Jan 10 '16 at 11:59
  • Have you also added the `controllers: { registrations: "registrations" }` to your routes? – Tobias Jan 10 '16 at 12:01
  • Yes, my routes looks like this: devise_for :users, controllers: { registrations: "registrations" } – Skodik.o Jan 10 '16 at 12:04
  • 2022: I ran into the same problem. However, given I was requiring users to confirm, they were registered as Inactive. Thus, I had to use `after_inactive_sign_up_path_for` instead. – Merovex Jun 12 '22 at 15:59