so i am trying to save to a join table in a habtm relationship, but i am
having problems.

from my view, i pass in a group id with:
= link_to "Create New User", new_user_url(:group => 1)

User model (user.rb)
class User < ActiveRecord::Base
  has_and_belongs_to_many :user_groups
  accepts_nested_attributes_for :user_groups
end

UserGroups model (user_groups.rb)
class UserGroup < ActiveRecord::Base
  has_and_belongs_to_many :users
end

users_controller.rb
def new
  @user = User.new(:user_group_ids => params[:group])
end

in the new user view, i have access to the User.user_groups object,
however when i submit the form, not only does it not save into my join
table (user_groups_users), but the object is no longer there.  all the
other objects & attributes of my User object are persistent except for
the user group.

i just started learning rails, so maybe i am missing something
conceptually here, but i have been really struggling with this.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to