메일에 MailChimp Api를 포함시키고 Gibbon gem in rails를 포함하려고합니다.레일 Gibbon Gem과 Mailchimp API 통합
메일 등을 추가하면 작동하며 콘솔의 API에서 올바른 콜백을 볼 수 있지만 이메일 ID div가 올바르게 변경되는 성공 사례는 제외하고 아무 일도 발생하지 않습니다.
케이스 스위치가 작동하지 않거나 API에서 돌아 오는 코드를 읽을 수없는 것 같습니다.
경로 등이 올바르게 설정되었습니다. 이 목록에 신선한 이메일을 추가 할 때 그것은 단지 작동
class MailchimpformController < ApplicationController
def index
end
def submit
mailchimp_api_key = "mysecretapikey"
mailchimp_list_id = "mysecretlistid"
g = Gibbon.new(mailchimp_api_key)
response = g.list_subscribe({:id => mailchimp_list_id,
:email_address => params[:email],
:double_optin => false,
:send_welcome => false})
if(response.is_a?(Hash))
puts response
case response['code']
when 502
@js_email_error = "Invalid Address!"
when 214
@js_email_error = "Already signed up!"
else
@js_email_error = response['error']
end
@js_email_success = nil
else
@js_email_success = "Thanks!"
@js_email_error = nil
end
respond_to do |format|
format.js
end
end
end
:
여기 내 컨트롤러입니다.
나는 또한 POST에 대한 Completed 500 Internal Server Error
를 받고있어
<% if @js_email_error %>
$("#email").val("<%= @js_email_error %>");
<% end %>
<% if @js_email_success %>
$("#email").val("<%= @js_email_success %>");
<% end %>
이/mailchimpform /를 (올바른)로 제출 index.html.erb
<%= form_tag submit_path, :class=> "form", remote: true do %>
<%= text_field_tag :email, nil, :class => 'email', :type=>"email", :placeholder => 'Sign up for beta testing' %>
<%= submit_tag "Absenden", :alt => "Absenden", class: "input-btn"%>
<% end %>
및 자바 스크립트 물건 submit.js.erb MailChimp API의 콜백. 왜 그런지 모르겠습니다.