I'm using Ruby on Rails and I would like to disable the double opt-it but have NFI how to do it.
How do I send the variable to the API?
Thank you
Here's a subscribe method you might use in a model for adding a user to a MailChimp mailing list:
  def subscribe
    mailchimp = Gibbon::API.new(Rails.application.secrets.mailchimp_api_key)
    result = mailchimp.lists.subscribe({
      :id => Rails.application.secrets.mailchimp_list_id,
      :email => {:email => self.email},
      :double_optin => false,
      :update_existing => true,
      :send_welcome => true
    })
    Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
  end
It uses the Gibbon gem. One of the key/value pairs in the hash is :double_optin => false.
The example is from my book, Learn Ruby on Rails, which includes a chapter showing how to build an application that allows a user to subscribe to a mailing list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With