Forgot to attach the patch! Here it is ...

-Jonathan.

On 7/28/06, Jonathan Viney <[EMAIL PROTECTED]> wrote:
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.

Attachment: dont_unnecessarily_save_has_one_association.diff
Description: Binary data

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

Reply via email to