Forum: Ruby on Rails Mailchimp or alternatives

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D14357247e224e2c7748f14a908e1f65?d=identicon&s=25 Travis Eubanks (eubanksanator)
on 2015-07-21 18:13
Im currently trying to just build a simple splash page  that has one
input field for a form which is their email.

Im trying to use the Mailchimp and gibbon gem.  When im on my localhost
and try to input my email and submit it.... nothing happens.  I get an
error in my terminal saying 500 error, email must contain one '@'....

WHICH it does contain only one.

Not sure why that error is being thrown.

My main goal is to just simple take a visitors email address they
inputed and send it to my mailchimp account for future mass emailing to
all that have signed up with me.
15eb13d662803f57bc4aea59704988b4?d=identicon&s=25 Scott Ribe (Guest)
on 2015-07-21 18:35
(Received via mailing list)
On Jul 21, 2015, at 10:13 AM, Travis Mr. <lists@ruby-forum.com> wrote:
>
> I guess what I'm trying to figure out is.... without any tables or
> models can I take in a users email address and sent it to my mailchimp
> account for future email marketing for my info.

Yes, you can do that, no problem.

You probably need to back up and provide us more info about what you're
doing and the exact error message.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice
D14357247e224e2c7748f14a908e1f65?d=identicon&s=25 Travis Eubanks (eubanksanator)
on 2015-07-22 02:17
Scott Ribe wrote in post #1176728:
> On Jul 21, 2015, at 10:13 AM, Travis Mr. <lists@ruby-forum.com> wrote:
>>
>> I guess what I'm trying to figure out is.... without any tables or
>> models can I take in a users email address and sent it to my mailchimp
>> account for future email marketing for my info.
>
> Yes, you can do that, no problem.
>
> You probably need to back up and provide us more info about what you're
> doing and the exact error message.
>

When I hit submit with my valid email address I get this error response
in my terminal

Started POST "/emailapi/subscribe" for ::1 at 2015-07-21 19:10:28 -0500
Processing by EmailapisController#subscribe as JS
  Parameters: {"utf8"=>"✓",
"email"=>{"address"=>"teubanks@tutelaholding.com"}, "commit"=>"Sign me
up for the abs!"}
Completed 500 Internal Server Error in 2490ms (ActiveRecord: 0.0ms)

Gibbon::MailChimpError (An email address must contain a single @):
  app/controllers/emailapis_controller.rb:8:in `subscribe'


-------CONTROLLER--------

class EmailapisController < ApplicationController
  def index
  end

  def subscribe
    gb = Gibbon::API.new(ENV['mailchimp_key'])

    gb.lists.subscribe({:id => ENV['mailchimp_id'],
      :email => {:email =>'address'}
      })
  end
end

-------VIEW--------

<div class="landing-box">
  <div class="call-action">
    <h1>Free weekly Ab Workouts!</h1>
    <h4>This isnt your typcal Richard Simmons routine.</h4>

    <%= form_tag('/emailapi/subscribe', method: "post", id: "subscribe",
remote: "true") do %>
    <%= email_field(:email, :address, {id: "email", placeholder: "email
address"}) %>
    <%= submit_tag("Sign me up for the abs!", :class => "btn
btn-success") %>
    <% end %>
  </div>
  <div class="col-md-8 col-md-offset-2">
    <div class="final-word">
      <p>Stop <i>GUESSING</i> what to do by getting weekly guides on
affective routines! Just type in your email and recieve a weekly ab
routine totally free!</p>
    </div>
  </div>
</div>
D14357247e224e2c7748f14a908e1f65?d=identicon&s=25 Travis Eubanks (eubanksanator)
on 2015-07-22 02:19
I totally feel that I'm missing some major but simple things here.  When
i submit the email address the site has NO visual errors just errors
shown are the ones in the terminal stated above
15eb13d662803f57bc4aea59704988b4?d=identicon&s=25 Scott Ribe (Guest)
on 2015-07-22 02:30
(Received via mailing list)
On Jul 21, 2015, at 6:17 PM, Travis Eubanks <lists@ruby-forum.com>
wrote:
>
>    gb.lists.subscribe({:id => ENV['mailchimp_id'],
>      :email => {:email =>'address'}
>      })

While I know nothing about that gem you're using, I suspect that it does
not take a key and then use it to access params. So you're in effect
trying to sign up with an address that is literally the string
'address'. Where the email address you obviously want to send to
MailChimp is in params[:email][:address].

I'd also question whether the gem really wants an argument of the form
:email => {:email => ...}, but I don't know that's wrong--something else
for you to check.
D14357247e224e2c7748f14a908e1f65?d=identicon&s=25 Travis Eubanks (eubanksanator)
on 2015-07-22 12:56
Scott Ribe wrote in post #1176738:
> On Jul 21, 2015, at 6:17 PM, Travis Eubanks <lists@ruby-forum.com>
> wrote:
>>
> While I know nothing about that gem you're using, I suspect that it does
> not take a key and then use it to access params. So you're in effect
> trying to sign up with an address that is literally the string
> 'address'. Where the email address you obviously want to send to
> MailChimp is in params[:email][:address].
>


This was it! I was sending in literally the string 'address' when i
needed to send in the params[:email][:address]

Thank for the help Scott!
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2015-07-22 20:16
(Received via mailing list)
On 22 July 2015 at 01:17, Travis Eubanks <lists@ruby-forum.com> wrote:
>> doing and the exact error message.
> Completed 500 Internal Server Error in 2490ms (ActiveRecord: 0.0ms)
>
>   def subscribe
>     gb = Gibbon::API.new(ENV['mailchimp_key'])
>
>     gb.lists.subscribe({:id => ENV['mailchimp_id'],
>       :email => {:email =>'address'}

Perhaps I don't understand the line above, but you appear to be
passing the string 'address' as the address.
This topic is locked and can not be replied to.