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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:01:08+00:00 2026-06-04T08:01:08+00:00

I have Group model that has_many institutions, and schools. class Group has_many :institutions has_many

  • 0

I have Group model that has_many institutions, and schools.

class Group
  has_many :institutions
  has_many :schools
end

However I need my Group to have_and_belongs_to_many :users but I want all the users that are associated through the institutions and schools like this:

class Group
  has_many :institutions
  has_many :users, :through => :instiutions
  has_many :schools
  has_many :users, :through => :schools
end

class School
  belongs_to :group      

  has_many :educations
  has_many :users, :through => :educations
end

class Institution
  belongs_to :group      

  has_many :institutional_educations
  has_many :users, :through => :institutional_educations
end

Obviously this isn’t possible so what should I do?

  • 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-04T08:01:09+00:00Added an answer on June 4, 2026 at 8:01 am

    Just offhand, have you considered using single table inheritance, so that school is a type of institution?

    Your School class would inherit from Institution (“class School < Institution”). Plus, I guess you’d call it something else but you could have “class GenericInstitution < Institution” as well. Then your Group class could look like this:

     class Group
      :has_many :school_users, :through => :schools, 
      :has_many :generic_institution_users, :through => :generic_institutions
    
       # if you need all of the users at once: 
       :has_many :users, :through => :institutions
     end
    

    You’d probably have to specify a foreign key or two to get this to work for you.

    Also, I can’t quite figure see what an :institutional_education is, but if you really need it you could do the same thing there (maybe “class institutional_education < education”, or maybe the other way around.

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

Sidebar

Related Questions

I have the following model structure: class Group < ActiveRecord::Base has_many :group_products, :dependent =>
I have a model class that has, among other things: class Group < ActiveRecord::Base
I have an ActiveRecord model that has two columns I want to group and
I have the following :has_many, :through association for my models: Group Model: has_many :group_users
I have a User model that has_many :posts. If I wanted to make a
I have a User and Group model. User has_many Groups and Group belongs_to User
If I have a class called Group, and in that class I have a
In my Rails app, I have the following objects: Group: has_many users through group_membership
I have a group model. I want to query a group to see if
I have a simple model class User has_many :logs class Logs related in the

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.