-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I've set up one-to-many association between users and ads (user has many ads, ad belongs to user) and have :autosave option set to true. When I reassign user's ads with 1 more ad it nullifies the user_id from the previous ad. Is this an intended behavior or a bug? Here is a simple test showing this case:
ad1 = Ad.create! ad2 = Ad.create! user = User.create!(ads: [ad1]) assert_equal [ad1], user.ads(true) user.ads = [ad1, ad2] user.save! assert_equal [ad1, ad2], user.ads(true) # fails, has only ad2