如何使用Gibbon on Rails将用户订阅到Mailchimp列表

时间:2014-11-12 09:16:45

标签: ruby-on-rails mailchimp gibbon

我正在尝试将用户订阅到mailchimp,不确定我是否在表单或控制器上发生错误,我在线跟踪了一些教程,但没有运气。

我会感激任何帮助 谢谢

以下是使用form_tag

的观点
<h1>Newsletter subscribe</h1>
<p>Sign up for email  updates</p>
<%= form_tag('subscribenow', method: "post", id: "subscribe", remote: "true") do %>
   <%= email_field(:email,:address, {id: "email", placeholder: "email address"}) %>
   <%= submit_tag("Sign me up!") %>
<% end %>

这是我的控制器

class EmailapiController < ApplicationController
def index
end

 def subscribe

    list_id = "my_id"
    gb = Gibbon::API.new

    gb.lists.subscribe({:id => list_id,
                        :email => {:email => 'email_address'}, 
                        :merge_vars => {:FNAME => 'First Name', 
                        :LNAME => 'Last Name'},             
                        :double_option => false})
 end
end

(这些是我在routes.rb文件中的路由)

get 'emailsignup'  => 'emailapi#index'
post 'subscribenow'=> 'emailapi#subscribe'

我的初始化文件

  Gibbon::API.api_key = "my_api_key"
  Gibbon::API.timeout = 15
  Gibbon::API.throws_exceptions = false

这是我在本地服务器上出现的错误

Started POST "/subscribenow" for 127.0.0.1 at 2014-11-12 07:49:10 -0800

ActiveRecord :: SchemaMigration Load(0.1ms)SELECT“schema_migrations”。* FROM“schema_migrations” 由EmailapiController处理#订阅为JS   参数:{“utf8”=&gt;“✓”,“email”=&gt; {“address”=&gt;“example@gmail.com”},“commit”=&gt;“注册我!”} 在353ms内完成500内部服务器错误

ActionView :: MissingTemplate(缺少模板emailapi / subscribe,应用程序/订阅{:locale =&gt; [:en],:formats =&gt; [:js,“application / ecmascript”,“application / x-ecmascript “,:html,:text,:js,:css,:ics,:csv,:vcf,:png,:jpeg,:gif,:bmp,:tiff,:mpeg,:xml,:rss,:atom, :yaml,:multipart_form,:url_encoded_form,:json,:pdf,:zip] ,: variants =&gt; [],:handlers =&gt; [:erb,:builder,:raw,:ruby,:jbuilder,:coffee搜索:   *“/Users/blanco/.rvm/gems/ruby-2.1.4/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates”   *“/ Users / blanco / Desktop / Rails_projects / dansbuzz / app / views”   *“/Users/blanco/.rvm/gems/ruby-2.1.4/gems/web-console-2.0.0.beta3/app/views” ):

0 个答案:

没有答案