From 230d7f760030c3400b682e4d8ffa1292ac1a9682 Mon Sep 17 00:00:00 2001 From: David Celis Date: Thu, 23 Aug 2012 07:44:43 -0700 Subject: Update the documentation for the :autosave option I've noticed a caveat with the :autosave option biting people before. Questions arise about why they must explicitly save an associated object in their own before_save callbacks. I've updated the documentation as such to note to users that the :autosave callback occurs before any user defined callbacks. They must save the associated record themselves if altering it in their own callbacks. Signed-off-by: David Celis --- activerecord/lib/active_record/associations.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 9ba3323bc7..d6b8552e6e 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1137,7 +1137,9 @@ module ActiveRecord # [:autosave] # If true, always save the associated objects or destroy them if marked for destruction, # when saving the parent object. If false, never save or destroy the associated objects. - # By default, only save associated objects that are new records. + # By default, only save associated objects that are new records. This option is implemented as a + # before_save callback. Because callbacks are run in the order they are defined, associated objects + # may need to be explicitly saved in any user-defined before_save callbacks. # # Note that accepts_nested_attributes_for sets :autosave to true. # [:inverse_of] -- cgit v1.2.3