Search code examples
ruby-on-railsrubydevisedevise-confirmable

Rails & Devise: How can I trigger other events when user registers?


For example a visitor will create an account I want to be able to trigger and create other things with those parameters until they confirm or login.

This is the closest solution I have, if it's not efficient please it would be great to give any suggestion

In application_controller.rb

class ApplicationController < ActionController::Base
   #other stuff
   after_filter :trigger_me, if: :devise_controller?
     def trigger_me
       #some code to execute
       #Some way to get User info just created.
     end
end

Solution

  • I think a better way to handle this would be in your User model through after_create callback(s) OR the other option if you need access to everything in the params hash would be to override the Devise RegistrationsController and add a callback to it, like discussed here: How to add callback after registration with Rails3 and Devise.