If the associated object of a has_one association has been loaded, it
is resaved when the parent is saved. Eg:

class Person < ActiveRecord::Base
 has_one :user
end

class User < ActiveRecord::Base
 belongs_to :person
end

p = Person.find(:first)
p.save # As expected, nothing happens with the user association
p.user # Loads the associated object
p.save # As well as saving the person, the user is saved as well.
Seems unnecessary.

Trac is down (or at least doesn't work for me), so I've attached a
patch that fixes the behaviour so that the child object is not saved
unnecessarily. Test included.

-Jonathan.
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to