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!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Guo Yangguang
2010-Jul-31 01:41 UTC
Re: how to understand callback and validate_associated
anyone help me? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Guo Yangguang
2010-Jul-31 07:00 UTC
Re: how to understand callback and validate_associated
hi who know about it? thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Jul-31 09:46 UTC
Re: how to understand callback and validate_associated
On Jul 31, 8:00 am, Guo Yangguang <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> hi > who know about it? thanks!Maybe you could rephrase your question - I for one couldn''t understand what you were asking Fred> -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Guo Yangguang
2010-Jul-31 10:49 UTC
Re: how to understand callback and validate_associated
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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Guo Yangguang
2010-Jul-31 14:43 UTC
Re: how to understand callback and validate_associated
I have described the problem clearly.Can you help me? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Jul-31 22:30 UTC
Re: how to understand callback and validate_associated
On Jul 31, 11:49 am, Guo Yangguang <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Guo Yangguang
2010-Aug-01 02:07 UTC
Re: how to understand callback and validate_associated
Thanks,fred. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.