我不知道为什么,但电子邮件没有传递到我的 Mailchimp 列表中。单击提交按钮不会执行任何操作。有什么想法吗?
宝石文件:
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
初始化器/长臂猿.rb:
Gibbon::API.api_key = "my api key is in here"
Gibbon::API.timeout = 15
Gibbon::API.throws_exceptions = false
路线.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