How to understand callback and validate_associated

1 after_update callback is wrapped in transaction means:no matter
exception occurs during saving an existing record, or in the
after_update method body,both the existing record and record
manipulation in the after_update body are all rollbacked?

2 class Book < ActiveRecord::Base
has_many :pages
validates_associated :pages
validates_presence_of :name
end

validate_associated means: when i invoke book.save to save book and it’s
associations,no matter invalidation occurs during saving book self or
saving any association,both book and all the associations don’t be
saved?

I don’t understand these from document.can you help me to make it sure?
Thanks!

anyone help me?

hi
who know about it? thanks!

On Jul 31, 8:00 am, Guo Y. [email protected] wrote:

hi
who know about it? thanks!

Maybe you could rephrase your question - I for one couldn’t understand
what you were asking

Fred

I have described the problem clearly.Can you help me?

thank!
I copy the after_update() doc as following:
#######
after_update()

Is called after Base.save on existing objects that have a record. Note
that this callback is still wrapped in the transaction around save. For
example, if you invoke an external indexer at this point it won’t see
the changes in the database.
########
I don’t understand “Note that this callback is still wrapped in the
transaction around save”.
if exception occurs when saving the existing record, or when executing
after_update method body,both the existing record’s saving and sql
statements in the after_update method body are all rollbacked?

On Jul 31, 11:49 am, Guo Y. [email protected] wrote:

########
I don’t understand “Note that this callback is still wrapped in the
transaction around save”.
if exception occurs when saving the existing record, or when executing
after_update method body,both the existing record’s saving and sql
statements in the after_update method body are all rollbacked?

Correct. The entirety of the save process (validations, before_save,
after_save etc.) is wrapped in a single transaction.

Fred

Thanks,fred.