From the image below.

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.

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
If you want to use the Rails convention, you should name your tables
users,groupsandgroups_usersand change:to:
If you want to keep the table names you described above, you have to do the following:
Note that table names are case sensitive. I used upper case, but that probably does not match your situation.