diff options
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/builder/has_one.rb | 2 |
2 files changed, 5 insertions, 5 deletions
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 |