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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:48:22+00:00 2026-06-13T21:48:22+00:00

So I have the following models in my program: class User < ActiveRecord::Base has_many

  • 0

So I have the following models in my program:

class User < ActiveRecord::Base
  has_many :group_members
  has_many :groups, through: :group_members 

class GroupMember < ActiveRecord::Base
  belongs_to :user
  belongs_to :group
end

class Group < ActiveRecord::Base
  has_many :group_members
  has_many :users, through: :group_members
end

And I’m using ActiveAdmin to administer these resources. My groups.rb file in the admin folder looks like this:

ActiveAdmin.register Group do
.
.
  belongs_to :user, :optional => true
.
.
end

The problem is, Group is a resource by itself – an admin can manage groups by going to the /admin/groups route – but it also is a resource of users, and I’m able to view the user groups by accessing the /admin/users/:user_id/groups route. However, when I try to create a new group to this user by accessing the /admin/users/:user_id/groups/new page and filling in the form, I get an error:

ActiveRecord::RecordNotFound in Admin::GroupsController#show
Couldn't find Group with id=13 [WHERE `group_members`.`user_id` = 2]

The user id corresponds to my currently logged in user and it is correct, while the group id = 13 corresponds to the id of the newly created group (it is saved in the database correctly), but the association in group_members table is not created. Actually, that’s not even exactly what I’m trying to achieve here: the ideal scenario would be to retrieve the list of groups and display it in the new page, so as not to create new groups in this page – only group_members.

How do I proceed in this case? Thanks in advance!

  • 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-13T21:48:23+00:00Added an answer on June 13, 2026 at 9:48 pm

    Have you considered removing the

    belongs_to
    

    declaration in the Group register block? The interface nesting that this aa dsl statement gives you, looks nice and gives you a clickpath, but, in the end it is merely a decoration on the data(model). Using filters and scopes in the user model could do as well. If you really need aa’s belongs_to you will have to create custom edit screens, and custom redirects. Good luck.

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

Sidebar

Related Questions

I have the following models: class Person < ActiveRecord::Base has_many :accounts, :through => :account_holders
I have the following models: class FieldEntryValue < ActiveRecord::Base belongs_to :field_entry end and class
Lets say we have following models. class User(db.Model): username=db.StringProperty() avatar=db.ReferenceProperty() class User(db.Model): username=db.StringProperty() avatar=db.StringProperty()
I am using Rails 3.2. I have following models: Blog Comment User class Blog
I have following model. class Comment(models.Model): type = models.CharField(max_length=21, choices=OBJECT_TYPE_CHOICES) program = models.ForeignKey(Program, db_column='object_id',
I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have the following models: class Foo has_and_belongs_to_many :bars end class Bar has_and_belongs_to_many :foos
I have the following models: class ProjectUser(models.Model): categories = models.ManyToManyField('UserCategory', blank=True, null=True) user_id =
I have the following Models and ViewModels (edited for brevity): public class Advert {
I have the following models class Person(models.Model): name = models.CharField(max_length=100) class Employee(Person): job =

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.