aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/callbacks.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-02 16:46:30 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-02 16:46:30 +0000
commit24a9050b6e34c859909f4e16ee68b8b34407a771 (patch)
tree777e5811e895dedfa83ade91b17a1a1d2b1db147 /activerecord/lib/active_record/callbacks.rb
parent74a612c4a15f3094e478aa79eb63b27efec8358a (diff)
downloadrails-24a9050b6e34c859909f4e16ee68b8b34407a771.tar.gz
rails-24a9050b6e34c859909f4e16ee68b8b34407a771.tar.bz2
rails-24a9050b6e34c859909f4e16ee68b8b34407a771.zip
Changed the callbacks such that observers are notified before the in-object callbacks are triggered. Without this change, it wasn't possible to act on the whole object in something like a before_destroy observer without having the objects own callbacks (like deleting associations) called first.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1273 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/callbacks.rb')
-rwxr-xr-xactiverecord/lib/active_record/callbacks.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 23675c3bd4..57745b344e 100755
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -328,6 +328,8 @@ module ActiveRecord
private
def callback(method)
+ notify(method)
+
callbacks_for(method).each do |callback|
result = case callback
when Symbol
@@ -345,9 +347,10 @@ module ActiveRecord
end
return false if result == false
end
-
- invoke_and_notify(method)
- true
+
+ send(method) if respond_to_without_attributes?(method)
+
+ return true
end
def callbacks_for(method)
@@ -355,8 +358,8 @@ module ActiveRecord
end
def invoke_and_notify(method)
- send(method) if respond_to_without_attributes?(method)
notify(method)
+ send(method) if respond_to_without_attributes?(method)
end
def notify(method) #:nodoc: