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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:46:24+00:00 2026-05-23T13:46:24+00:00

From the image below. It can be seen that I have three table User,

  • 0

From the image below.

enter image description here

It can be seen that I have three table User, User_group and group. I am trying to link a user to user_group and Group to user_group in other words link a user to a user_group. Currently in my user model I have the following:

User.rb
has_and_belongs_to_many :group

Group.rb
has_and_belongs_to_many :user

What I am basically trying to do is import the data into the User_group table. What is the best way around this. Tried searching online and have had no luck.

enter image description here

Form Layout

The user should be able to assign themselves to a group. When they click update the information entered should be saved to the user_group 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-05-23T13:46:24+00:00Added an answer on May 23, 2026 at 1:46 pm

    If you want to use the Rails convention, you should name your tables users, groups and groups_users and change:

    has_and_belongs_to_many :group
    has_and_belongs_to_many :user
    

    to:

    has_and_belongs_to_many :groups
    has_and_belongs_to_many :users
    

    If you want to keep the table names you described above, you have to do the following:

    class User < ActiveRecord::Base
      set_table_name 'USER'
      has_and_belongs_to_many :groups, :join_table => 'USER_GROUP'
    end
    
    class Group < ActiveRecord::Base
      set_table_name 'GROUP'
      has_and_belongs_to_many :users, :join_table => 'USER_GROUP'
    end
    

    Note that table names are case sensitive. I used upper case, but that probably does not match your situation.

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

Sidebar

Related Questions

Below is an image from a site that hase user photo's, they link to
As you can see from the image below, the Java text is horizontal. What
Apart from using image on the button, how can I write X Y on
Im loading an image from a SQL CE db and then trying to load
I have taken an image from UIImagePickerController , but the file looks too big
I have developed a simple site that fetches tweets from the Twitter public timeline,
I have one table which display data as from Dynamic Content in 1 column.
I am trying to remove a certain color from my image however it's not
My app requires an image uploader which either takes an image from the user's
Please look at the image below !! So in this image... You can see

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.