Gibbon Gem Mailchimp表格问题

时间:2016-01-28 22:54:07

标签: ruby-on-rails ruby mailchimp gibbon

我不确定原因,但是电子邮件没有传递到我的Mailchimp列表。单击“提交”按钮不会执行任何操作。有什么想法吗?

的Gemfile:

gem 'gibbon', '~> 1.0.0'

index.html.erb:

<%= form_tag('/welcome/subscribe', method: "post", id: "subscribe", remote: "true") do -%>
   <%= email_field(:email, :address, {id: "email", placeholder: "email address", :class=>"email form-control"}) %>
   <%= submit_tag("Sign me up!", :class=>"btn btn-palette") %>
<% end %>

模型/ welcome.rb:

def subscribe

@list_id = "my list id is in here"
gb = Gibbon::API.new

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

初​​始化/ gibbon.rb:

Gibbon::API.api_key = "my api key is in here"
Gibbon::API.timeout = 15
Gibbon::API.throws_exceptions = false

routes.rb中:

post 'welcome/subscribe' => 'welcome#subscribe'
  root 'welcome#index'

控制器/ welcome_controller.rb:

class WelcomeController < ApplicationController
  def index
  end

  def subscribe

    @list_id = "my list id is in here"
    gb = Gibbon::API.new

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

1 个答案:

答案 0 :(得分:0)

在此处使用此代码解决了问题:Mailchimp gem double_optin false not working

但是有双重选择的问题=&gt;假的