JoHksi JoHksi - 1 year ago 46
Ruby Question

Accessing newly singed up user in Rails app using devise

I am currently making Rails app using devise.
After a new user signs up, I need to access newly singed up user's information to run my customized function.
However it seems like devise's

is nil since the user is not logged in yet until the user confirms the email.

I essentially just need to check whether user's
is nil.

Is there a way to do this?

Answer Source

I would do this in the User model with a callback:

# in app/model/user.rb (assuming you have a User model)
after_create :run_customized_function

  def run_customized_function
    # whatever need to be done with this user, for example: 
    #"User##{id} just signed up with email '#{email}'")