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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:17:48+00:00 2026-06-04T20:17:48+00:00

Here is my model structure: A User has and belongs to many groups A

  • 0

Here is my model structure:

A User has and belongs to many groups
A Group has many subscriptions
A Group has and belongs to many users
A Group has many GroupAdmins
A Subscription belongs to a group
A GroupAdmin belongs to a user
A GroupAdmin belongs to a Group

When I query the DB (using active record), I should be able to do something like this:

u = User.find 47238

In my User model I have a method called subscriptions:

def subscriptions
    self.groups.where(:status => 'active').collect { |group| group.subscriptions.where("subscriptions.status = ? AND subscriptions.expiration_date > ?", 'active', "#{Time.zone.now}").last  }.flatten
  end

and then to continue with my query:

u.subscriptions.first.group.group_admins

The above returns me a record of a group and the user id I initally queried on.. but for some reason when I run this method inside of Group I get a false returned:

def is_group_admin?(user)
    self.group_admins.include? user
  end

Working Code:

def is_admin?(user)
    self.group_admins.collect { |ga| ga.user }.include? user
  end
  • 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-04T20:17:50+00:00Added an answer on June 4, 2026 at 8:17 pm

    group_admins returns a collection of GroupAdmin objects. These may correspond (via their user_id) to a user but they aren’t actually users so group_admins.include?(user) can only return false.

    Depending on what you are doing you could call include? on group_admins.collect {|ga| ga.user} or search for a GroupAdmin with the appropriate user_id value.

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

Sidebar

Related Questions

Here is model structure: Client is User, Client can be corporate or person: class
Here is model of my table structure. Three tables. ---------------- ---------------------------- ------------------------------- |possibilities |
here is my model class gameUserTrophyInfo(models.Model): user = models.ForeignKey(userInfo) trophy = models.ForeignKey(gameTrophyInfo) date =
Here's my user model: class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable,
Here's a snippet from my application: class PortolioItem(models.Model): ... user = models.ForeignKey(User) contract =
I have the following model structure class User(db.Model) : nickname = db.StringProperty(required=True) fullname =
I have a nested model structure that looks like this: resources :users, :path =>
Here is the model we are using to store the CC details how secure
I've got an interesting box-model problem here. I have a header full of links,
Here is a Django model I'm using. class Person(models.Model): surname = models.CharField(max_length=255, null=True, blank=True)

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.