Created
August 12, 2011 01:48
-
-
Save jeffdeville/1141266 to your computer and use it in GitHub Desktop.
New code to convert facebook user to User2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def map_user(fbuser, token) | |
| user2 = User2.new | |
| %w[name email].each { |field| user2.send("#{field}=", fbuser[field]) } | |
| %w[first_name last_name birthday gender website timezone updated_time relationship_status locale third_party_id].each do |field| | |
| user2.profile.send("#{field}=", fbuser[field]) | |
| end | |
| %w[interests activities music books movies television likes games religion favorite_teams favorite_athletes inspirational_people sports].each do |field| | |
| next if fbuser[field].blank? | |
| data = case fbuser[field] | |
| when Hash then fbuser[field]["data"] | |
| else fbuser[field] | |
| end | |
| user2.profile.interests += data.map do |int| | |
| FbPage.new :fb_id => int["id"], :name => int["name"], :category => int["category"] | |
| end.to_set | |
| end | |
| user2.fb_id = fbuser["id"] | |
| user2.access_token = token | |
| user2 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment