2

I know once the user has confirmed a Confirmable account in devise, I can change the redirect URL with:

def after_confirmation_path_for(resource)
  view_context.admin_dashboard_url_for(subdomain: resource.tenant.subdomain)
end

But if I wanted to call a custom method on the resource after confirmation, how would I do that with devise? I suppose I could stick it in this method...

 def after_confirmation_path_for(resource)
   resource.do_thing_after_confirmation
   view_context.admin_dashboard_url_for(subdomain: resource.tenant.subdomain)
 end

But that doesn't feel right to have this method changing the model.

typeoneerror
  • 55,990
  • 32
  • 132
  • 223
  • override confirmations controller with your own, define same method, do your action and then call `super()` – Avdept Aug 15 '14 at 13:19

1 Answers1

5

I found a blank method in Devise::Models::Confirmable that is called during the confirm! method. I'm going to override this method in my User resource model and do my work here.

def after_confirmation
end
typeoneerror
  • 55,990
  • 32
  • 132
  • 223