Skip to content

Commit

Permalink
actually displaying the facebook results(first time connection), upda…
Browse files Browse the repository at this point in the history
…ting attributes instead of discarding the changes
  • Loading branch information
Ilyaaaaaaaaaaaaa Zhitomirskiy committed Jul 11, 2011
1 parent 58e844e commit f6bf178
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/services/facebook.rb
Expand Up @@ -23,6 +23,7 @@ def finder(opts = {})
Rails.logger.debug("event=friend_finder type=facebook sender_id=#{self.user_id}")
if self.service_users.blank?
self.save_friends
self.service_users.reload
else
Resque.enqueue(Job::UpdateServiceUsers, self.id)
end
Expand All @@ -42,8 +43,8 @@ def save_friends
response = Faraday.get(url)
data = JSON.parse(response.body)['data']
data.each{ |p|
ServiceUser.find_or_create_by_service_id_and_uid(:service_id => self.id, :name => p["name"],
:uid => p["id"], :photo_url => p["picture"])
su = ServiceUser.find_or_initialize_by_service_id_and_uid(:service_id => self.id, :uid => p["id"])
su.update_attributes({:name => p["name"], :photo_url => p["picture"]})
}
end
end

0 comments on commit f6bf178

Please sign in to comment.