Skip to content
Newer
Older
100644 91 lines (79 sloc) 3.15 KB
64fcf4b Will Paginate: add WillPaginate::Deprecation that builds on ActiveSup…
mislav authored Oct 13, 2007
1 require 'active_support'
dbc3975 @mislav require core_ext before trying to use `include_method?` in `enable_ac…
authored Jun 2, 2009
2 require 'will_paginate/core_ext'
64fcf4b Will Paginate: add WillPaginate::Deprecation that builds on ActiveSup…
mislav authored Oct 13, 2007
3
c7ec4a5 Will Paginate docs and contributors
mislav authored Sep 27, 2007
4 # = You *will* paginate!
5 #
6 # First read about WillPaginate::Finder::ClassMethods, then see
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
7 # WillPaginate::ViewHelpers. The magical array you're handling in-between is
8 # WillPaginate::Collection.
c7ec4a5 Will Paginate docs and contributors
mislav authored Sep 27, 2007
9 #
10 # Happy paginating!
11 module WillPaginate
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
12 class << self
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 14, 2008
13 # shortcut for <tt>enable_actionpack</tt> and <tt>enable_activerecord</tt> combined
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
14 def enable
15 enable_actionpack
16 enable_activerecord
17 end
18
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
19 # hooks WillPaginate::ViewHelpers into ActionView::Base
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
20 def enable_actionpack
b63e438 @mislav check for method existance in a ruby 1.8- and 1.9-compatible way
authored May 20, 2009
21 return if ActionView::Base.instance_methods.include_method? :will_paginate
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
22 require 'will_paginate/view_helpers'
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
23 ActionView::Base.send :include, ViewHelpers
4598470 @mislav Rescue from WillPaginate::InvalidPage error with 404 Not Found.
authored Mar 3, 2008
24
efe2c81 @mislav big refactoring in view tests; rewrite most of them in much nicer way…
authored Apr 6, 2008
25 if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
4598470 @mislav Rescue from WillPaginate::InvalidPage error with 404 Not Found.
authored Mar 3, 2008
26 ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found
27 end
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
28 end
29
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
30 # hooks WillPaginate::Finder into ActiveRecord::Base and classes that deal
138f004 Will Paginate Christmas doc love
mislav authored Dec 25, 2007
31 # with associations
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
32 def enable_activerecord
33 return if ActiveRecord::Base.respond_to? :paginate
34 require 'will_paginate/finder'
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
35 ActiveRecord::Base.send :include, Finder
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
36
17a05b7 @mislav crazy monkeypatching to enable named_scope on associations in Rails 1…
authored Apr 5, 2008
37 # support pagination on associations
b00a298 @mislav fix will_paginate for yet another Rails edge change (r9230)
authored Apr 6, 2008
38 a = ActiveRecord::Associations
39 returning([ a::AssociationCollection ]) { |classes|
40 # detect http://dev.rubyonrails.org/changeset/9230
41 unless a::HasManyThroughAssociation.superclass == a::HasManyAssociation
42 classes << a::HasManyThroughAssociation
43 end
44 }.each do |klass|
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
45 klass.send :include, Finder::ClassMethods
46 klass.class_eval { alias_method_chain :method_missing, :paginate }
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
47 end
8c31282 @mislav Rails 2.3.2 compat: monkeypatch issue #2189 (count breaks has_many :t…
authored May 20, 2009
48
49 # monkeypatch Rails ticket #2189: "count breaks has_many :through"
50 ActiveRecord::Base.class_eval do
51 protected
52 def self.construct_count_options_from_args(*args)
53 result = super
54 result[0] = '*' if result[0].is_a?(String) and result[0] =~ /\.\*$/
55 result
56 end
57 end
e65d717 @mislav opt-in for named_scope with WillPaginate.enable_named_scope (because …
authored Apr 5, 2008
58 end
0036735 @mislav backport ActiveRecord named_scope from Rails 2.1
authored Mar 26, 2008
59
e65d717 @mislav opt-in for named_scope with WillPaginate.enable_named_scope (because …
authored Apr 5, 2008
60 # Enable named_scope, a feature of Rails 2.1, even if you have older Rails
61 # (tested on Rails 2.0.2 and 1.2.6).
1694bb8 @mislav document WillPaginate.enable_named_scope(false)
authored Apr 5, 2008
62 #
63 # You can pass +false+ for +patch+ parameter to skip monkeypatching
64 # *associations*. Use this if you feel that <tt>named_scope</tt> broke
65 # has_many, has_many :through or has_and_belongs_to_many associations in
66 # your app. By passing +false+, you can still use <tt>named_scope</tt> in
67 # your models, but not through associations.
e65d717 @mislav opt-in for named_scope with WillPaginate.enable_named_scope (because …
authored Apr 5, 2008
68 def enable_named_scope(patch = true)
69 return if defined? ActiveRecord::NamedScope
70 require 'will_paginate/named_scope'
71 require 'will_paginate/named_scope_patch' if patch
72
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
73 ActiveRecord::Base.send :include, WillPaginate::NamedScope
b40c221 Reorganize the complete will_paginate loading process to be modular. …
mislav authored Oct 6, 2007
74 end
75 end
64fcf4b Will Paginate: add WillPaginate::Deprecation that builds on ActiveSup…
mislav authored Oct 13, 2007
76
48d409a @mislav RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
authored Aug 13, 2008
77 module Deprecation # :nodoc:
64fcf4b Will Paginate: add WillPaginate::Deprecation that builds on ActiveSup…
mislav authored Oct 13, 2007
78 extend ActiveSupport::Deprecation
79
80 def self.warn(message, callstack = caller)
5bd4767 @mislav deprecation notices if you use a collection that responds to old `pag…
authored Apr 4, 2008
81 message = 'WillPaginate: ' + message.strip.gsub(/\s+/, ' ')
62b9f6c @dejan Make WillPaginate::Deprecation.warn output the caller
dejan authored Jan 10, 2009
82 ActiveSupport::Deprecation.warn(message, callstack)
64fcf4b Will Paginate: add WillPaginate::Deprecation that builds on ActiveSup…
mislav authored Oct 13, 2007
83 end
84 end
c7ec4a5 Will Paginate docs and contributors
mislav authored Sep 27, 2007
85 end
4ca58bb @mislav add CHANGELOG covering the 2.2.0 release
authored Apr 7, 2008
86
fce2e9e @gcirne load will_paginate view helpers even if ActiveRecord is not loaded
gcirne authored Apr 21, 2009
87 if defined? Rails
88 WillPaginate.enable_activerecord if defined? ActiveRecord
89 WillPaginate.enable_actionpack if defined? ActionController
4ca58bb @mislav add CHANGELOG covering the 2.2.0 release
authored Apr 7, 2008
90 end
Something went wrong with that request. Please try again.