diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index 9626df08aaab8006d7544605884456bc12d0d1c9..188a06e4480232e49b252ed36375e35bbf438057 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -204,43 +204,37 @@ module ActiveRecord # # Sometimes the code needs that the callbacks execute in a specific order. For example, a +before_destroy+ # callback (log_children in this case) should be executed before the children get destroyed by the - # dependant destroy option. + # dependent destroy option. # # Let's take at the code below: # # class Topic < ActiveRecord::Base - # - # has_many :children, dependant: destroy + # has_many :children, dependent: destroy # # before_destroy :log_children # - # def log_children - # children.each do |child| - # # Some child processing + # private + # def log_children + # # Child processing # end - # end - # # end # # In this case the problem is that when the +before_destroy+ is executed, the children are not available - # because the dependant destroy gets executed first. To solve this issue it is possible - # to use the +prepend+ option on the +before_destroy+ callback. + # because the dependent destroy gets executed first. To solve this issue it is possible to use the + # +prepend+ option on the +before_destroy+ callback. # # class Topic < ActiveRecord::Base - # - # has_many :children, dependant: destroy + # has_many :children, dependent: destroy # # before_destroy :log_children, prepend: true # - # def log_children - # children.each do |child| - # # Some child processing + # private + # def log_children + # # Child processing # end - # end - # # end # - # This way, the +before_destroy+ gets executed before the dependant: destroy is called, and + # This way, the +before_destroy+ gets executed before the dependent: destroy is called, and # the data is still available. # # == Transactions