rails-prelaunch-signup
rails-prelaunch-signup copied to clipboard
MailChimp API error while running migration and creating DEFAULT USERS
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.
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.
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:in
method_missing'
/Users/erikjosue6/rails_project/cemibox-prelaunch-signup/app/models/user.rb:66:in `add_user_to_mailchimp'
and then the callbacks ...
Any suggestions?
Is the ADMIN_EMAIL environment variable set?
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
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
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.
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
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.
Just a matter of using log statements to debug.
Thank you and will do from now on.