Skip to content

Instantly share code, notes, and snippets.

@jcohenho
Last active December 21, 2015 02:28
Show Gist options
  • Save jcohenho/6235001 to your computer and use it in GitHub Desktop.
Save jcohenho/6235001 to your computer and use it in GitHub Desktop.
back-end request for retrieving users
##########
def filter
@users = User.where facebook_id: params[:facebook_ids]
respond_with @users
end
front-end request in Coffeescript/Backbone for retrieving the list of FB friends
##########
getListOfFacebookFriends: ->
ids = null
FB.api('/me/friends', (response) =>
ids = _.pluck(response.data, 'id')
if ids.length == 0
hide_certain_elements()
else
@fetchFacebookFriendsOnGOOD(response.data)
)
fetchGOODFacebookFriends: (FBFriends) ->
ids = _.pluck(FBFriends, 'id')
friends = new good.citizen.collections.FacebookFriends
friends.fetch
data: {facebook_ids: ids},
type: 'POST',
success: (GOODFriends) =>
@showFriendsOnGOODToFollow(GOODFriends)
@showFriendsNotOnGOODToInvite(FBFriends, GOODFriends)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment