Skip to content
Browse files

Rails 2.3.2 compat: monkeypatch issue #2189 (count breaks has_many :t…

…hrough)
  • Loading branch information...
1 parent 6109da7 commit 8c31282cb683c0acba7566e6f57f5d516598c3ab @mislav mislav committed May 20, 2009
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/will_paginate.rb
View
10 lib/will_paginate.rb
@@ -44,6 +44,16 @@ def enable_activerecord
klass.send :include, Finder::ClassMethods
klass.class_eval { alias_method_chain :method_missing, :paginate }
end
+
+ # monkeypatch Rails ticket #2189: "count breaks has_many :through"
+ ActiveRecord::Base.class_eval do
+ protected
+ def self.construct_count_options_from_args(*args)
+ result = super
+ result[0] = '*' if result[0].is_a?(String) and result[0] =~ /\.\*$/
+ result
+ end
+ end
end
# Enable named_scope, a feature of Rails 2.1, even if you have older Rails

0 comments on commit 8c31282

Please sign in to comment.
Something went wrong with that request. Please try again.