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 6215983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:09:12+00:00 2026-05-24T07:09:12+00:00

I have users with nested resources posts. I have a page that shows all

  • 0

I have users with nested resources posts. I have a page that shows all posts from all users. However, on the left column I want to categorize them by user, as follows, with links to a URL with a parameter like ?username=laura, for example, to show only their posts. I’m pretty sure I can figure out the URL params, but getting them sorted, as shown below, is difficult for me. Any suggestions? Thanks!

Adam (23)

Brad (12)

Mike (1)

  • 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-24T07:09:12+00:00Added an answer on May 24, 2026 at 7:09 am
    Users.includes(:posts).map{|u| [u.name, u.posts.count, u.id]}.sort
    

    Will give you a sorted array of users, post counts, and user id like

    [
     ["Adam", 23, 23],
     ["Brad", 12, 2],
     ["Mike", 1, 44]
    ]
    

    You can this user the first two elements for your link and the user id for the link destination.

    This might get slow with thousands of users and/or posts, but it should get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have users table and i have posts table i want select from users
If I have a nested resource like so: resources :users resources :posts end and
I have a nested model structure that looks like this: resources :users, :path =>
I have an ASP.NET page that uses a repeater nested within another repeater to
I have a form for a nested resource (Client :has_many Workouts) that I want
I have a set of nested resources -- :users and :messages. resources :users, :only
I have queried on user posts (nested resources, obviously) and have a long list
Users have many websites, and Websites have many Keywords. (Keywords being nested resources of
I have a resource nested in another: resource :users do resource :posts end The
I have a List object, with nested Tasks. I have created a page that

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.