Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changeing some code-styles of the examples & fix a typo on dependent …

…option
  • Loading branch information...
commit 3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2 1 parent d4db095
@elpic elpic authored
Showing with 12 additions and 18 deletions.
  1. +12 −18 activerecord/lib/active_record/callbacks.rb
View
30 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 <tt>dependant: destroy</tt> is called, and
+ # This way, the +before_destroy+ gets executed before the <tt>dependent: destroy</tt> is called, and
# the data is still available.
#
# == Transactions
Please sign in to comment.
Something went wrong with that request. Please try again.