Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6546383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:42:03+00:00 2026-05-25T11:42:03+00:00

I have Facebook likes saved in a table (they’re in a string) and do

  • 0

I have Facebook likes saved in a table (they’re in a string) and do the following in the console to return the likes using the like method for the user model:

User.first.likes

=> "--- !seq:Koala::Facebook::GraphCollection \n- name: Rome Sweet Rome\n  category:
   Book\n  id: \"136333439795671\"\n  created_time: 2011-09-05T12:03:09+0000\n- name:
   Drawn Together\n category: Tv show\n  id: \"8694990902\"\n  created_time:
   2008-10-03T10:39:46+0000\n"

Below it is in YAML:

y User.first.likes

--- |
 --- !seq:Koala::Facebook::GraphCollection 
 - name: Rome Sweet Rome
 category: Book
 id: "136333439795671"
 created_time: 2011-09-05T12:03:09+0000
 - name: Drawn Together
 category: Tv show
 id: "8694990902"
 created_time: 2008-10-03T10:39:46+0000

 => nil

I want the end result to give me something like:

>> ["Rome sweet Rome", "Drawn Together"]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:42:03+00:00Added an answer on May 25, 2026 at 11:42 am

    Split the string into separate lines, delimited by the \n character (or if it comes across as the string “\n”, use double-quotes to delimit on that string)

    like_elements = User.first.likes.split("\n") # <- String, not character, delimited version
    => ['id: "136333439795671"', 'created_time: 2011-09-05T12:03:09+0000", "- name: Drawn Together" ... etc.]
    

    Then collect all elements that start with “- name: ” into their own array:

    name_elements = like_elements.select{|s| s.start_with?("- name: ")}
    => ["- name: Drawn Together", "- name: Rome sweet Rome"]
    

    Then take each of the elements in name_elements and strip out the leading "- name: " text, and remove leading an trailing whitespace

    names_of_likes_only = name_elements.collect{|n| n.gsub("- name: ", "").strip}
    => ["Drawn Together", "Rome sweet Rome"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes class Facebook { String fid String name User user static
I have a facebook connect site using the c# facebook toolkit. I want to
I have an application in facebook platform (a trial application) and i am using
Does anyone know the recommended way of creating a FaceBook 'likes' button using the
I have integrated the facebook in my app using http://sourceforge.net/projects/facebook-bb-sdk , it work fine
I have a web app shown in an Iframe on Facebook and I'm using
I have an IEnumerable full of objects that we are using to represent user
I have a Facebook application with multiple Like buttons on it. When you click
I have the following situation in a Ruby on Rails app: user fills in
I have a JSON response from Facebook liking like this. [ {uid=>123, name=>Test, is_app_user=>true},

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.