aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-04-11 01:10:42 +0000
committerRick Olson <technoweenie@gmail.com>2006-04-11 01:10:42 +0000
commit7e76740d2a5ee14b308c7e40f9c95354d19f6189 (patch)
tree83a89c7dec2b409749a0728aaa7897662ba11dc9 /activerecord/lib/active_record
parent98634e776191123294f644b0b8444f50df2677e9 (diff)
downloadrails-7e76740d2a5ee14b308c7e40f9c95354d19f6189.tar.gz
rails-7e76740d2a5ee14b308c7e40f9c95354d19f6189.tar.bz2
rails-7e76740d2a5ee14b308c7e40f9c95354d19f6189.zip
Allow multiple association extensions with :extend option (closes #4666) [Josh Susser]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4206 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb8
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb2
2 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 369983632d..f862d9e777 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -215,6 +215,14 @@ module ActiveRecord
# has_many :people, :extend => FindOrCreateByNameExtension
# end
#
+ # If you need to use multiple named extension modules, you can specify an array of modules with the :extend option.
+ # In the case of name conflicts between methods in the modules, methods in modules later in the array supercede
+ # those earlier in the array. Example:
+ #
+ # class Account < ActiveRecord::Base
+ # has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension]
+ # end
+ #
# === Association Join Models
#
# Has Many associations can be configured with the :through option to use an explicit join model to retrieve the data. This
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index 403c036db5..adf7ad6ac6 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -8,7 +8,7 @@ module ActiveRecord
def initialize(owner, reflection)
@owner, @reflection = owner, reflection
- proxy_extend(reflection.options[:extend]) if reflection.options[:extend]
+ Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) }
reset
end