Permalink
Browse files

Deprecated the AssociationCollection constant

  • Loading branch information...
1 parent 0f37def commit fb95dee9264efa86d1024fbb42a79bd877d1a10d @jonleighton jonleighton committed Jul 16, 2011
View
@@ -1,5 +1,13 @@
*Rails 3.1.0 (unreleased)*
+* Deprecated the AssociationCollection constant. CollectionProxy is now the appropriate constant
+ to use, though be warned that this is not really a public API.
+
+ This should solve upgrade problems with the will_paginate plugin (and perhaps others). Thanks
+ Paul Battley for reporting.
+
+ [Jon Leighton]
+
* ActiveRecord::MacroReflection::AssociationReflection#build_record has a new method signature.
Before: def build_association(*options)
@@ -1,5 +1,12 @@
+require 'active_support/deprecation'
+
module ActiveRecord
module Associations
+ AssociationCollection = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
+ 'ActiveRecord::Associations::AssociationCollection',
+ 'ActiveRecord::Associations::CollectionProxy'
+ )
+
# Association proxies in Active Record are middlemen between the object that
# holds the association, known as the <tt>@owner</tt>, and the actual associated
# object, known as the <tt>@target</tt>. The kind of association any proxy is
@@ -1599,4 +1599,23 @@ def build_association(*options)
undef_method :old_build_association
end
end
+
+ def test_AssociationCollection_deprecated
+ assert_deprecated do
+ ActiveRecord::Associations::AssociationCollection.class_eval do
+ def foo
+ "bar"
+ end
+ end
+ end
+
+ author = Author.new
+ assert_equal "bar", author.posts.foo
+ ensure
+ ActiveSupport::Deprecation.silence do
+ ActiveRecord::Associations::AssociationCollection.class_eval do
+ undef_method :foo
+ end
+ end
+ end
end

0 comments on commit fb95dee

Please sign in to comment.