Skip to content

Instantly share code, notes, and snippets.

@joesavak
Created May 20, 2011 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joesavak/983692 to your computer and use it in GitHub Desktop.
Save joesavak/983692 to your computer and use it in GitHub Desktop.
savefbuid.rb
def savefbuid
user = current_user
fbuid = params[:fbuid]
fbaccess = params[:fbaccess]
user.fb_uid = fbuid
user.fbaccess = fbaccess
@graph = Koala::Facebook::GraphAPI.new(fbaccess)
@me = @graph.get_object("me")
if @me['username'].blank?
user.fbusername = @me['name']
un = @me['name']
else
user.fbusername = @me['username']
un = @me['username']
end
user.save!
respond_to do |format|
format.js do
render :json => {"username" => un}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment