aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder/collection_association.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-02 15:28:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-02 15:28:59 -0700
commit7a38eae0075b4f38462be267fa80a4ff366fdd00 (patch)
tree60090e23ea084c1446cdeae5d56b06a9fb611b4e /activerecord/lib/active_record/associations/builder/collection_association.rb
parent0091808a081e85d4f44631984fa8a54ddf345868 (diff)
parentb86a4965b8532286430b7cd9b359a2574d745b92 (diff)
downloadrails-7a38eae0075b4f38462be267fa80a4ff366fdd00.tar.gz
rails-7a38eae0075b4f38462be267fa80a4ff366fdd00.tar.bz2
rails-7a38eae0075b4f38462be267fa80a4ff366fdd00.zip
Merge branch 'master' into habtm
* master: we can define callbacks without a builder instance push methods that don't depend on the instance to the class get the name from the reflection cache the name and options on the stack decouple belongs_to callback definition from the builder instance. add_before_destroy_callbacks doesn't depend on the instance, so push it to the class. valid_options doesn't depend on the instance, so push it to the class use the information on the reflection to determine whether callbacks should be added Running all isolated test for actionview association builder is no longer needed for counter cache, so remove it push constructable? on to the reflection Adds the Rails maintenance policy to the Guides name is on the reflection, so just use the reflection decouple define_callback from the instance Added activemodel as a explicit dependency unify `Fixes` notes in AR changelog. [ci skip]. improving `reload` doc wording. #12418 [ci skip] Update AR reload doc for the case of manually set primary key attribute [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/collection_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/builder/collection_association.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb
index 7bd0687c0b..15f9f9a65f 100644
--- a/activerecord/lib/active_record/associations/builder/collection_association.rb
+++ b/activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -23,9 +23,13 @@ module ActiveRecord::Associations::Builder
end
end
- def define_callbacks(model, reflection)
+ def self.define_callbacks(model, reflection)
super
- CALLBACKS.each { |callback_name| define_callback(model, callback_name) }
+ name = reflection.name
+ options = reflection.options
+ CALLBACKS.each { |callback_name|
+ define_callback(model, callback_name, name, options)
+ }
end
def define_extensions(model)
@@ -35,7 +39,7 @@ module ActiveRecord::Associations::Builder
end
end
- def define_callback(model, callback_name)
+ def self.define_callback(model, callback_name, name, options)
full_callback_name = "#{callback_name}_for_#{name}"
# TODO : why do i need method_defined? I think its because of the inheritance chain