I’m using twitter and facebook to connect to a website. When the provider is facebook I want to add the users email to the database field when its twitter there should be no email. The code below keeps timing out my server.
def self.from_omniauth(auth)
where(provider: auth['provider'], uid: auth['uid']).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.profile_data = auth.info
user.email = auth.info.email unless user.email.nil?
user.token = auth['credentials']['token'] unless auth['credentials'].nil?
user.secret = auth['credentials']['secret'] unless auth['credentials'].nil?
end
end
I’ve also tried
def self.from_omniauth(auth)
where(provider: auth['provider'], uid: auth['uid']).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.profile_data = auth.info
user.email = auth.info.email unless auth.info.email?
user.token = auth['credentials']['token'] unless auth['credentials'].nil?
user.secret = auth['credentials']['secret'] unless auth['credentials'].nil?
end
end
Error on heroku:
2012-08-21T23:30:07+00:00 heroku[router]: Error H12 (Request timeout) -> GET www.myapp.com/ dyno=web.1 queue= wait= service=30000ms status=503 bytes=0
Try this:
This checks for the auth hash for nil and empty values.