public
Rubygem
Description: Most awesome pagination solution for Ruby
Homepage: http://github.com/mislav/will_paginate/wikis
Clone URL: git://github.com/mislav/will_paginate.git
Click here to lend your support to: will_paginate and make a donation at www.pledgie.com !
simplify association mixin code and fix pagination on HMT associations with edge 
Rails [9200]
Mislav Marohnić (author)
Wed Apr 02 19:40:10 -0700 2008
commit  dfda32a6e3fe252dc62c06044958b3033d8b35c7
tree    f6ec1eb6b80d6902e94ebbef6b5c23bfccaee81f
parent  3d3c21f8e5af174cb79cfaa99a50908bf4ac2f7f
...
33
34
35
 
36
37
 
 
 
 
 
38
39
40
41
42
43
44
 
45
46
47
...
33
34
35
36
37
38
39
40
41
42
43
44
 
 
 
 
 
 
45
46
47
48
0
@@ -33,15 +33,16 @@ module WillPaginate
0
       require 'will_paginate/finder'
0
       ActiveRecord::Base.class_eval { include Finder }
0
 
0
+      # support paginating finders on associations
0
       associations = ActiveRecord::Associations
0
       collection = associations::AssociationCollection
0
+      classes = [collection]
0
+      # before [9200], HMT wasn't a subclass of AssociationCollection
0
+      unless associations::HasManyThroughAssociation.superclass == collection
0
+        classes << associations::HasManyThroughAssociation
0
+      end
0
       
0
-      # to support paginating finders on associations, we have to mix in the
0
-      # method_missing magic from WillPaginate::Finder::ClassMethods to AssociationProxy
0
-      # subclasses, but in a different way for Rails 1.2.x and 2.0
0
-      (collection.instance_methods.include?(:create!) ?
0
-        collection : collection.subclasses.map(&:constantize)
0
-      ).push(associations::HasManyThroughAssociation).each do |klass|
0
+      classes.each do |klass|
0
         klass.class_eval do
0
           include Finder::ClassMethods
0
           alias_method_chain :method_missing, :paginate

Comments