Check for nil before building ServiceUser objects
This commit is contained in:
parent
1a72be544f
commit
201574c53a
1 changed files with 1 additions and 0 deletions
|
|
@ -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)}"
|
url = "https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=#{URI.escape(self.access_token)}"
|
||||||
response = Faraday.get(url)
|
response = Faraday.get(url)
|
||||||
data = JSON.parse(response.body)['data']
|
data = JSON.parse(response.body)['data']
|
||||||
|
return unless data
|
||||||
data.map!{ |p|
|
data.map!{ |p|
|
||||||
su = ServiceUser.new(:service_id => self.id, :uid => p["id"], :photo_url => p["picture"], :name => p["name"])
|
su = ServiceUser.new(:service_id => self.id, :uid => p["id"], :photo_url => p["picture"], :name => p["name"])
|
||||||
su.attach_local_models
|
su.attach_local_models
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue