Check for nil before building ServiceUser objects

This commit is contained in:
Raphael Sofaer 2011-08-06 14:02:27 -07:00
parent 1a72be544f
commit 201574c53a

View file

@ -36,6 +36,7 @@ class Services::Facebook < Service
url = "https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=#{URI.escape(self.access_token)}"
response = Faraday.get(url)
data = JSON.parse(response.body)['data']
return unless data
data.map!{ |p|
su = ServiceUser.new(:service_id => self.id, :uid => p["id"], :photo_url => p["picture"], :name => p["name"])
su.attach_local_models