سؤال

Currently I have a Rails 3 app that subscribes new users up to MailChimp. As part of my user model, I have this:

after_create :add_user_to_mailchimp
before_destroy :remove_user_from_mailchimp
before_save :update_mailchimp_values

Then, each of those three actions are some variation on this:

def add_user_to_mailchimp  
  mailchimp = Hominid::API.new(MAILCHIMP_API_KEY)
  list_id = mailchimp.find_list_id_by_name MAILCHIMP_LIST_NAME

  info = { }
  mailchimp.list_subscribe(list_id, self.email, info, 'html', false, true, false, false))
end

The problem is that this is slowing down the registration process... It can take 3 or 4 seconds to return, and I'm worried that once the floodgates open on the site (later today, probably), it'll be ridiculously out of hand.

Is there an easy way to make this faster, or do I need to set up something like delayed_job?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top