diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 15:08:18 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 15:28:49 -0700 |
commit | 743f1a9094c0b6f7b47a9dad211a6b2b77bdb85a (patch) | |
tree | b7e714a1b82fd2c31bd0f16ec03a6725aaee00e5 /activerecord/lib/active_record | |
parent | 22f05afb2d79f8088e49710d4e9e3ba1883bf11e (diff) | |
download | rails-743f1a9094c0b6f7b47a9dad211a6b2b77bdb85a.tar.gz rails-743f1a9094c0b6f7b47a9dad211a6b2b77bdb85a.tar.bz2 rails-743f1a9094c0b6f7b47a9dad211a6b2b77bdb85a.zip |
add_before_destroy_callbacks doesn't depend on the instance, so push it
to the class.
Diffstat (limited to 'activerecord/lib/active_record')
-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 |