-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
The following code will create a correct HABTM relationship
User.create(:login => login, :password => 'password', :password_confirmation => 'password') do |u|
u.company = Company.first
u.admin = true
end
u = User.first
u.groups << Group.first
However the following code:
User.create(:login => login, :password => 'password', :password_confirmation => 'password') do |u|
u.company = Company.first
u.admin = true
u.groups << Group.first
end
results in the following
User.first.groups => [#<Group _id: 4e6d540a8625ee28d2000002, name: "test group", created_at: Mon Sep 12 00:36:26 UTC 2011, updated_at: Mon Sep 12 00:36:26 UTC 2011, user_ids: [], _type: nil, company_id: BSON::ObjectId('4e6d540a8625ee28d2000001')>] Group.first.users => []