diff options
author | Xavier Noria <fxn@hashref.com> | 2010-03-12 20:23:39 +0100 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-03-12 11:53:22 -0800 |
commit | fe43bbd8c71fabb4b612808c42461b2ba9655318 (patch) | |
tree | 55ea320a347a5fe7449777430282c618d935736e /activerecord/lib/active_record/associations | |
parent | 611744ebd33d04bb302bf12f627d36ca59041caf (diff) | |
download | rails-fe43bbd8c71fabb4b612808c42461b2ba9655318.tar.gz rails-fe43bbd8c71fabb4b612808c42461b2ba9655318.tar.bz2 rails-fe43bbd8c71fabb4b612808c42461b2ba9655318.zip |
keep AssociationProxy#to_a to avoid warning in Array(post.author), and delegate it to @target in association collections
[#4165 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 9487d16123..6eda70d0ce 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -101,6 +101,7 @@ module ActiveRecord Array(@target) end end + alias_method :to_a, :to_ary def reset reset_target! diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 022dd2ae9b..0ff89df1e3 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -49,7 +49,7 @@ module ActiveRecord alias_method :proxy_respond_to?, :respond_to? alias_method :proxy_extend, :extend delegate :to_param, :to => :proxy_target - instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^object_id$)/ } + instance_methods.each { |m| undef_method m unless m =~ /^(?:nil\?|send|object_id|to_a)$|^__|proxy_/ } def initialize(owner, reflection) @owner, @reflection = owner, reflection |