Calin
Calin

Reputation: 6847

Rails - Devise lag when sending welcome email

I send a welcome email to a user after he was create using the following code in my model:

after_create :send_welcome_email
...

def send_welcome_email
  EmailerUtilizator.welcome_email(self).deliver
end

I do this with an ajax call, the delived method has a short but noticeable delay. Shall I use an async method ? Or shall I use some sort of waiting animation ?

Thank you,

Upvotes: 2

Views: 249

Answers (1)

Michael De Silva
Michael De Silva

Reputation: 3818

Perhaps combine with delayed_job? If they receive an email in 2-3 minutes even it's acceptable and also consider the scenario of concurrent registrations!

def send_welcome_email
  EmailerUtilizator.delay.welcome_email(self)
end

Upvotes: 4

Related Questions