Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MailChimp API error while running migration and creating DEFAULT USERS #51

Open
erikjosue6 opened this issue Oct 9, 2013 · 11 comments
Open

Comments

@erikjosue6
Copy link

I've been trying to run the migration for the db and theres is an error when trying to create the email address provided for the Admin by the ENV variable.

DEFAULT USERS
user: Erik Santiago
rake aborted!
MailChimp API Error: This email address looks fake or invalid. Please enter a real email address (code -100)

I must say that I wanted to user my name and email account to create the Admin but for some reason it is not working.

@DanielKehoe
Copy link
Member

You won't need the admin added to the MailChimp list. In user.rb, the add_user_to_mailchimp method will not be executed if the email address matches ENV['ADMIN_EMAIL'.

You may find it easier to run the migration with the default and then change it in the admin dashboard.

@erikjosue6
Copy link
Author

I brought the application to the default with the only difference that I'm using gmail in development as instructed in one your tutorials. For the other part everything should be the same but still getting the error.

ROLES
role: admin
role: user
DEFAULT USERS
user: First User
rake aborted!
MailChimp API Error: This email address looks fake or invalid. Please enter a real email address (code -100)
/Users/erikjosue6/.rvm/gems/ruby-1.9.3-p448@cemibox-prelaunch-signup/gems/gibbon-1.0.4/lib/gibbon/api_category.rb:35:in call' /Users/erikjosue6/.rvm/gems/ruby-1.9.3-p448@cemibox-prelaunch-signup/gems/gibbon-1.0.4/lib/gibbon/api_category.rb:45:inmethod_missing'
/Users/erikjosue6/rails_project/cemibox-prelaunch-signup/app/models/user.rb:66:in `add_user_to_mailchimp'

and then the callbacks ...

Any suggestions?

@DanielKehoe
Copy link
Member

Is the ADMIN_EMAIL environment variable set?

@erikjosue6
Copy link
Author

Yes to [email protected].

ADMIN_NAME: First User
ADMIN_EMAIL: [email protected]
ADMIN_PASSWORD: changeme
ROLES: [admin, user]
EMAIL_ADDRESS: [email protected]
DOMAIN: example.com

@DanielKehoe
Copy link
Member

See what happens when you add log statements to the user.rb file:

  def add_user_to_mailchimp
    Rails.logger.info "step 1 value is #{ENV['ADMIN_EMAIL']}"
    return if email.include?(ENV['ADMIN_EMAIL'])
    Rails.logger.info "step 2 value is #{ENV['ADMIN_EMAIL']}"
    mailchimp = Gibbon::API.new
    result = mailchimp.lists.subscribe({
      :id => ENV['MAILCHIMP_LIST_ID'],
      :email => {:email => self.email},
      :double_optin => false,
      :update_existing => true,
      :send_welcome => true
      })
    Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
  end

@erikjosue6
Copy link
Author

The 2 values are as expected

step 1 value is [email protected]
step 2 value is [email protected]
�[1m�[35m (1.9ms)�[0m rollback transaction

I'm sorry to bother you at this hour but haven't found any question on Stackoverflow or google or describing the error.

@DanielKehoe
Copy link
Member

Try this:

 def add_user_to_mailchimp
    Rails.logger.info "admin email is #{ENV['ADMIN_EMAIL']}"
    Rails.logger.info "user email is #{self.email}"
    return if self.email.include?(ENV['ADMIN_EMAIL'])
    Rails.logger.info "you shouldn't see this msg if user email and admin email are the same"
    mailchimp = Gibbon::API.new
    result = mailchimp.lists.subscribe({
      :id => ENV['MAILCHIMP_LIST_ID'],
      :email => {:email => self.email},
      :double_optin => false,
      :update_existing => true,
      :send_welcome => true
      })
    Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
  end

@erikjosue6
Copy link
Author

I think that solved the issue since for some reason which i don't know it was taking the ADMIN_EMAIL and comparing it with the email for the second user in the seed.rb file

admin email is [email protected]
user email is [email protected]
you shouldn't see this msg if user email and admin email are the same

Once I erased the user2 extract the process finished.

@DanielKehoe
Copy link
Member

Just a matter of using log statements to debug.

@erikjosue6
Copy link
Author

Thank you and will do from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@DanielKehoe @erikjosue6 and others