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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:25:05+00:00 2026-06-10T15:25:05+00:00

Let me display a sketch of needed models: 1) I’ve a Unit model it’s

  • 0

Let me display a sketch of needed models:

1) I’ve a Unit model
it’s connected (has a foreign key) to the Type model. has_many :People

2)Type – it’s a simple model, a string ‘name’ – like (‘first’,’second’, etc)

3) Person model – just a person.

What i need to do’s output:
each type with all the units, each with all the people of this unit

OR
How can i access unit’s type via person record?

  • 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-10T15:25:06+00:00Added an answer on June 10, 2026 at 3:25 pm

    So, i’ve solved this problem.
    The query goes something like this:

    Person.includes(units: [:type]).
    order(Units.title).group_by {|p| p.unit.type}.
    map {|type, v| { type=> v.group_by{|p| p.unit}
    

    Sorry if i didn’t describe the question properly.

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

Sidebar

Related Questions

so let's say I have a registration model and I have: [Display(Name = )]
Let's say I wanted to display a Button and a few RadioButtons . Based
Let's say I have cleaner like this .cleaner:after { content: '.'; display: block; clear:
I want to display NSE/BSE quote in my PHP website. please let me know
In my rails app I'd like to let users submit custom themes to display
This is pure curiosity. Let's write an object: var display = { res1:{ w:640,
I need a Swing component that will let me display a tree-structured list of
Please help, I am building a Java applet, and it wont let me display
Let's say I want to display the specials module on the homepage in a
Let's say I have a list of products. I want to display a list

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.