Gibbon Mailchimp integration simply not working

195 views Asked by At

View

<%= form_tag('/posts/subscribe', method: "post", id: "subscribe", remote: "true") do %>
    <div class="large-18 columns text-right mailer">
    <%= email_field(:email, :address, {id: "mailersub", placeholder: "Enter your email"}) %>
    </div>
    <div class="large-6 columns text-right mailer">
        <%= submit_tag("Submit", id: "mailersubmit") %>
    </div>
<% end %>

Posts controller

  def subscribe

    @list_id = "01d4732307"
    gb = Gibbon::API.new

    gb.lists.subscribe({
      :id => @list_id,
      :email => {:email => params[:email][:address]}
      })

  end

Routes

  resources :posts do
    member do
       post :subscribe
    end
  end

Initializer

 Gibbon::API.api_key = "5dbfa9b02dd8a28aa43937d19234da5e-us9"
  Gibbon::API.timeout = 15
  Gibbon::API.throws_exceptions = false

When I click submit it just does nothing, I'm not sure what I'm doing wrong. Here is the guide I was trying to follow: http://cheshireoctopus.github.io/blog/2014/01/23/mailchimp-plus-gibbon-plus-rails-create-a-basic-sign-up-form/

1

There are 1 answers

0
ZazOufUmI On

The question is a little old but since there is no answer, it may help someone someday.

If this happens to you, it's maybe because users being added are in a pending state, they have to opt-in to be fully subscribed. Try to add the parameter double_optin to false as explained in the API documentation.

gb.lists.subscribe({
      :id => @list_id,
      :email => {:email => params[:email][:address]},
      :double_optin => false
      })