Skip to content

Commit

Permalink
Rails 2.3.2 compat: monkeypatch issue #2189 (count breaks has_many :t…
Browse files Browse the repository at this point in the history
…hrough)
  • Loading branch information
mislav committed May 20, 2009
1 parent 6109da7 commit 8c31282
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/will_paginate.rb
Expand Up @@ -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
Expand Down

0 comments on commit 8c31282

Please sign in to comment.