habtm + accepts_nested_attributes_for

so i have read conflicting information about this, some seem to pull it off, some say its impossible, but here is what i am trying to accomplish. i am using authlogic w/ lockdown, and when i create a new user, i want to add an entry into the user_groups_users join table with the new user id, and a group id i pass it. i have tried several variations, but here is what i ended up with (edited down to only pertinent info).

User model [code] class User < ActiveRecord::Base   has_and_belongs_to_many :user_groups   accepts_nested_attributes_for :user_groups end [/code]

UserGroup model [code] class UserGroup < ActiveRecord::Base   has_and_belongs_to_many :users end [/code]

users_controller [code] def new   @user = User.new(:user_group_ids => params[:group]) # gets passed in from /users/new?group=1   @user.user_groups.build #i have tried with and without this. with it, i get duplicate ID fields in my view   end [/code]

view form (haml) [code] - form_for @user do |f|     - f.fields_for :user_groups do |g|       = g.text_field :id [/code]

if i fill out all the required fields, the user fields are saved, but no user_groups_users entry is made if i sumbit the form with just the user_groups_user id, the field dissapears, but in my params, i see

[code]     user: !map:HashWithIndifferentAccess       user_groups_attributes: !map:HashWithIndifferentAccess         "0": !map:HashWithIndifferentAccess           id: "1" [/code]

i admit, i am a r00bie, so maybe i am going about this entirely wrong. but can anyone offer any input?

thanks