@@ -15,23 +15,6 @@ module WillPaginate
15
15
# @posts = Post.paginate :all, :page => params[:page], :order => 'created_at DESC'
16
16
#
17
17
module ActiveRecord
18
- # In Rails, this is automatically called to mix-in pagination functionality to ActiveRecord.
19
- def self . setup
20
- ::ActiveRecord ::Base . extend PerPage
21
- ::ActiveRecord ::Base . extend ActiveRecord ::Pagination
22
- ::ActiveRecord ::Base . extend ActiveRecord ::BaseMethods
23
-
24
- klasses = [ ::ActiveRecord ::Relation ]
25
- if defined? ::ActiveRecord ::Associations ::CollectionProxy
26
- klasses << ::ActiveRecord ::Associations ::CollectionProxy
27
- else
28
- klasses << ::ActiveRecord ::Associations ::AssociationCollection
29
- end
30
-
31
- # support pagination on associations and scopes
32
- klasses . each { |klass | klass . send ( :include , ActiveRecord ::Pagination ) }
33
- end
34
-
35
18
# makes a Relation look like WillPaginate::Collection
36
19
module RelationMethods
37
20
attr_accessor :current_page
@@ -192,5 +175,20 @@ def paginate_by_sql(sql, options)
192
175
end
193
176
end
194
177
end
178
+
179
+ # mix everything into Active Record
180
+ ::ActiveRecord ::Base . extend PerPage
181
+ ::ActiveRecord ::Base . extend Pagination
182
+ ::ActiveRecord ::Base . extend BaseMethods
183
+
184
+ klasses = [ ::ActiveRecord ::Relation ]
185
+ if defined? ::ActiveRecord ::Associations ::CollectionProxy
186
+ klasses << ::ActiveRecord ::Associations ::CollectionProxy
187
+ else
188
+ klasses << ::ActiveRecord ::Associations ::AssociationCollection
189
+ end
190
+
191
+ # support pagination on associations and scopes
192
+ klasses . each { |klass | klass . send ( :include , Pagination ) }
195
193
end
196
194
end
0 commit comments