刚刚整合了Gibbon,gem和我收到的主机名与尝试订阅新用户时抛出的服务器证书错误不符?
def subscribe_to_mailchimp testing=false
return true if (Rails.env.test? && !testing)
list_id = ENV['My-list-id']
response = Rails.configuration.mailchimp.lists.subscribe({
id: list_id,
email: {email: email},
double_optin: false,
})
response
end
答案 0 :(得分:3)
从我上一次看起来这种方式的微小变化似乎已经解决了这个问题。
首先
def subscribe_to_mailchimp testing=false
return true if (Rails.env.test? && !testing)
list_id = 'My-list-id'
response = Rails.configuration.mailchimp.lists.subscribe({
id: list_id,
email: {email: email},
double_optin: false,
})
response
end
其次
在config / initializers / mailchimp.rb
中if Rails.env.test?
Gibbon::Export.api_key = "fake"
Gibbon::Export.throws_exceptions = false
end
Gibbon::API.api_key = "YOUR_API_KEY"
Gibbon::API.timeout = 15
Gibbon::API.throws_exceptions = false
Rails.configuration.mailchimp = Gibbon::API.new
最后在application.rb
require 'openssl'
要求openssl是生成主机名与服务器错误不匹配的内容,因为Gibbon应用程序中的调用使用https
如果您对users.rb感兴趣
def subscribe_to_mailchimp testing=false
return true if (Rails.env.test? && !testing)
list_id = "YOUR_LIST_ID"
response = Rails.configuration.mailchimp.lists.subscribe({
id: list_id,
email: {email: email},
double_optin: false,
})
response
end