1

我正在尝试为用户订阅 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#subscribe 作为 JS 处理参数:{"utf8"=>"✓", "email"=>{"address"=>" example@gmail.com"}, "commit"=>"Sign me up!"} 在 353 毫秒内完成 500 内部服务器错误

ActionView::MissingTemplate (缺少模板 emailapi/subscribe, application/subscribe with {:locale=>[:en], :formats=>[: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=>[], :handlers=>[: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/意见" * "/Users/blanco/.rvm/gems/ruby-2.1.4/gems/web-console-2.0.0.beta3/app/views"):

4

0 回答 0