Update data in has_and_belongs_to_many

Hello, I have my model Email and Group.

I have the migration CreateEmailsGroupsJoin

create_table :emails_groups, :id => false do |t|
      t.references :email
      t.references :group

And in my email_controller, I make a update for my data, but I can't
change the value of my group_id, in the migration. I can change the
values on email data only.

@email = Email.find( params[ :id ] )

    if @email.update_attributes( params[ :email ] )
      flash[ :notice ] = ""
      redirect_to :action => "list"
      render "edit"

I want to know where I change in this code above to edit my group too.