aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPablo Ifran <pabloifran@gmail.com>2012-10-22 09:38:57 -0200
committerPablo Ifran <pabloifran@gmail.com>2012-10-22 09:38:57 -0200
commit3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2 (patch)
treeaa18bb1b42de71465e57a378d4a9eef04a555d40 /activerecord
parentd4db09514cc3f18d1d157caaf0784bedf38fafe8 (diff)
downloadrails-3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2.tar.gz
rails-3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2.tar.bz2
rails-3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2.zip
Changeing some code-styles of the examples & fix a typo on dependent option
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/callbacks.rb30
1 files changed, 12 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 9626df08aa..188a06e448 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 <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