From 743f1a9094c0b6f7b47a9dad211a6b2b77bdb85a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 2 Oct 2013 15:08:18 -0700 Subject: add_before_destroy_callbacks doesn't depend on the instance, so push it to the class. --- .../lib/active_record/associations/builder/association.rb | 8 ++++---- activerecord/lib/active_record/associations/builder/has_one.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index e6da251550..dd2a6415b4 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -69,7 +69,7 @@ module ActiveRecord::Associations::Builder end def define_callbacks(model, reflection) - add_before_destroy_callbacks(model, reflection) if reflection.options[:dependent] + self.class.add_before_destroy_callbacks(model, reflection) if reflection.options[:dependent] Association.extensions.each do |extension| extension.build model, reflection end @@ -110,9 +110,9 @@ module ActiveRecord::Associations::Builder private - def add_before_destroy_callbacks(model, reflection) - unless self.class.valid_dependent_options.include? reflection.options[:dependent] - raise ArgumentError, "The :dependent option must be one of #{self.class.valid_dependent_options}, but is :#{reflection.options[:dependent]}" + def self.add_before_destroy_callbacks(model, reflection) + unless valid_dependent_options.include? reflection.options[:dependent] + raise ArgumentError, "The :dependent option must be one of #{valid_dependent_options}, but is :#{reflection.options[:dependent]}" end name = reflection.name diff --git a/activerecord/lib/active_record/associations/builder/has_one.rb b/activerecord/lib/active_record/associations/builder/has_one.rb index a2509b5bae..f359efd496 100644 --- a/activerecord/lib/active_record/associations/builder/has_one.rb +++ b/activerecord/lib/active_record/associations/builder/has_one.rb @@ -16,7 +16,7 @@ module ActiveRecord::Associations::Builder private - def add_before_destroy_callbacks(model, reflection) + def self.add_before_destroy_callbacks(model, reflection) super unless reflection.options[:through] end end -- cgit v1.2.3