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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:04:06+00:00 2026-06-05T21:04:06+00:00

I have the following :has_many, :through association for my models: Group Model: has_many :group_users

  • 0

I have the following :has_many, :through association for my models:

Group Model:

has_many :group_users
has_many :users, :through => :group_users

Users Model:

has_many :group_users
has_many :groups, :before_add => :validates_group, :through => :group_users

GroupsUsers Model:

belongs_to :group
belongs_to :user

In the groups_users table, I have an additional column that keeps up with the users status (active or inactive). I need to be able to update that column when a user removes them self from a group. How can you use update_attributes on a join table?

  • 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-05T21:04:09+00:00Added an answer on June 5, 2026 at 9:04 pm

    There’s something a little odd about that, so just to be sure–normally you would remove a user from a group by deleting the groups_user record that holds the connection.

    If you want that record to persist and just be marked inactive, then you are saying that the user will continue to show up in the group’s users collection, and vice versa.

    Assuming that is indeed what you want–the record is updateable like any other. You can get to it from either either the user or group side and then edit as usual.

    eg, for a user u, group g, groups_user gu

    gu = g.groups_users.where('user_id = ?',u.id) 
    gu.update_attributes (:status => 'inactive')
    

    also, note that if you do this there are probably going to be many times when you want only the active users for a group, or the active groups for a user. See this post for how to do that in this circumstance: Rails has_many :through Find by Extra Attributes in Join Model

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

Sidebar

Related Questions

I have the following class: class Group < ActiveRecord::Base has_many :users belongs_to :leader, :foreign_key
I have the following models: class Person < ActiveRecord::Base has_many :accounts, :through => :account_holders
I have the following model association: a student model and has_many scores. I need
I have the following models: Post.rb class Post < ActiveRecord::Base belongs_to :category has_many :attachments,
I have the following model structure: class Group < ActiveRecord::Base has_many :group_products, :dependent =>
I have a current association where: Group :has_many Employees and Employee :belongs_to Group but
I'm trying to setup a simple has_many :through => association. I have 3 models.
We have the following model: payment.rb: class Payment < ActiveRecord::Base has_many :currencies default_scope :include
Okay, at the moment I have the following in my model: has_many :current_monitorings, :class_name
I have two models, Worker and Project, and they are connected with has_many through

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.