From fe43bbd8c71fabb4b612808c42461b2ba9655318 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 12 Mar 2010 20:23:39 +0100 Subject: 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 --- activerecord/lib/active_record/associations/association_collection.rb | 1 + activerecord/lib/active_record/associations/association_proxy.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3