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

  • SEARCH
  • Home
  • 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 8271399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:49:49+00:00 2026-06-08T06:49:49+00:00

I am trying group ever User friends by highschool, the user signs in with

  • 0

I am trying group ever User friends by highschool, the user signs in with his facebook account, I use facebook graph to get all his friends.

This code here outputs/print first all User friends and prints the groups every friend by highschool. I dont want that, I only want it to output/print the groups.

<ul class="friends-list">
<% current_user.friends.group_by(&:highschool_name).map do |hsname, friends| %>
   <li><%= hsname %></li> 
   <% friends.map do |friend| %>
   <%= image_tag(friend.image) %> 
 <% end %>
 <% end %>
</ul>

The User tabel:

[id, name, image, location, highschool_name, highschool_year, college_name, college_year, graduteschool_name, graduate_year ]

The Friend tabel:

[id, uid, name, image, higschool_name, college_name, graduateschool_name, user_id]

The current output in more details:

Started GET "/users/1" for 127.0.0.1 at 2012-07-16 01:10:17 +0200
Processing by UsersController#show as HTML
  Parameters: {"id"=>"1"}
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", "1"]]
  Rendered users/_profile_content.html.erb (0.6ms)
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 1]]
  Friend Load (9.2ms)  SELECT "friends".* FROM "friends" WHERE "friends"."user_id" = 1
  Rendered users/show.html.erb within layouts/application (287.4ms)
  Rendered layouts/_shim.html.erb (0.1ms)
  Rendered layouts/_header.html.erb (2.3ms)
  Rendered layouts/_footer.html.erb (0.6ms)
Completed 200 OK in 321ms (Views: 309.3ms | ActiveRecord: 9.8ms)

A image of the output:
http://postimage.org/image/tgyl9f27n/

  • 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-06-08T06:49:51+00:00Added an answer on June 8, 2026 at 6:49 am

    The problem:
    some values in the database that was empty. Gives the error

    The solution:

    <% next if hsname.blank? %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to get all the images from a facebook group using facebook API
Group, I am sure this is user error somehow, but I am trying to
I'm trying to group table values by date, and this HQL query works fine:
I am trying to group by a substring. I only get the one result:
I want to use addIntentOptions to drive my menus when ever possible. This seems
Basically I'm trying to group my arrays like this: Shopping Amazon Social Amoeblo American
I'm trying to group together radiobuttons that are creating using a for loop and
I'm trying to group some sets in disjoint sets. For example, if I have
I am trying to group some data without much luck. I have a list
I'm trying to group a set of data based on the range of an

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.