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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:57:59+00:00 2026-06-07T15:57:59+00:00

Given the following models: User (id) has_many :groups has_many :communities Groups (community_id (OPTIONAL) )

  • 0

Given the following models:

User (id)
  has_many :groups
  has_many :communities

Groups (community_id (OPTIONAL) )
  belongs_to :user
  belongs_to :community

Communities (id, archived (boolean) )
  has_many :groups
  has_many :group_members, :include => :user

I can easily get a user’s groups by doing:

current_user.groups

The problem is if a community is archived, I don’t want that returned in the current_user.groups.

How can I get all of a user’s groups where the community is not archived?

Thanks

  • 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-07T15:58:02+00:00Added an answer on June 7, 2026 at 3:58 pm

    current_user.groups.joins(:community).where('communities.archived' => false)

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

Sidebar

Related Questions

Given the following models: User.rb NetworkDepartment.rb (id, title,added_by) belongs_to :user, :foreign_key => :added_by I
Given the following Thread belongs_to :user User has_many :threads, :through => :thread_members When I
Given the following models: team.rb class Team < ActiveRecord::Base has_many :events, :dependent => :destroy
Given the following model: class User < AR::B has_many :permissions has_many :projects, :through =>
I have the following models, with their relevant associations: class User < ActiveRecord::Base has_many
Given the following ActiveRecord model: class User < ActiveRecord::Base has_many :games def name Joe
I have the following models: Account has_many :libraries Library has_many :topics belongs_to :account Topic
Given the following two models: User (id) FbFriendCache(user_id,fb_user_id) I would like to be able
I have following models: User has_many :roles, :through => :assignments Role has_many :assignments has_many
Given the following models: class Post(models.Model): title = models.CharField(max_length=200) html = models.TextField() class PostTag(models.Model):

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.