aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/autosave_association.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index b30d1eb0a6..f31cbb499c 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -143,16 +143,16 @@ module ActiveRecord
module ClassMethods
private
- def define_non_cyclic_method(name, reflection, &block)
+ def define_non_cyclic_method(name, &block)
define_method(name) do |*args|
result = true; @_already_called ||= {}
# Loop prevention for validation of associations
- unless @_already_called[[name, reflection.name]]
+ unless @_already_called[name]
begin
- @_already_called[[name, reflection.name]]=true
+ @_already_called[name]]=true
result = instance_eval(&block)
ensure
- @_already_called[[name, reflection.name]]=false
+ @_already_called[name]=false
end
end
@@ -180,7 +180,7 @@ module ActiveRecord
if collection
before_save :before_save_collection_association
- define_non_cyclic_method(save_method, reflection) { save_collection_association(reflection) }
+ define_non_cyclic_method(save_method) { save_collection_association(reflection) }
# Doesn't use after_save as that would save associations added in after_create/after_update twice
after_create save_method
after_update save_method
@@ -197,14 +197,14 @@ module ActiveRecord
after_create save_method
after_update save_method
else
- define_non_cyclic_method(save_method, reflection) { save_belongs_to_association(reflection) }
+ define_non_cyclic_method(save_method) { save_belongs_to_association(reflection) }
before_save save_method
end
end
if reflection.validate? && !method_defined?(validation_method)
method = (collection ? :validate_collection_association : :validate_single_association)
- define_non_cyclic_method(validation_method, reflection) { send(method, reflection) }
+ define_non_cyclic_method(validation_method) { send(method, reflection) }
validate validation_method
end
end