Wednesday 15 February 2012

how to subscribe a user to a Mailchimp list using Gibbon on Rails -



how to subscribe a user to a Mailchimp list using Gibbon on Rails -

i'm trying subscribe users mailchimp, not sure if i'm making error on form or controller , followed tutorials online haven't had no luck.

i'll appreciated help give thanks you

here view using form_tag

<h1>newsletter subscribe</h1> <p>sign email updates</p> <%= form_tag('subscribenow', method: "post", id: "subscribe", remote: "true") %> <%= email_field(:email,:address, {id: "email", placeholder: "email address"}) %> <%= submit_tag("sign me up!") %> <% end %>

this controller

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

(these routes on routes.rb file)

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

my initializer file

gibbon::api.api_key = "my_api_key" gibbon::api.timeout = 15 gibbon::api.throws_exceptions = false

this error on local server

started post "/subscribenow" 127.0.0.1 @ 2014-11-12 07:49:10 -0800

activerecord::schemamigration load (0.1ms) select "schema_migrations".* "schema_migrations" processing emailapicontroller#subscribe js parameters: {"utf8"=>"✓", "email"=>{"address"=>"example@gmail.com"}, "commit"=>"sign me up!"} completed 500 internal server error in 353ms

actionview::missingtemplate (missing template emailapi/subscribe, application/subscribe {: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]}. searched in: * "/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" ):

ruby-on-rails mailchimp gibbon

No comments:

Post a Comment