Commit http://github.com/rails/rails/commit/517bc500ed95a84fd2aadff34fdc14cb7965bc6b introduced the new method proxy_respond_to?, but it has a bug.
Suppose the following case (it’s using will_paginate plugin)
class User < ActiveRecord::Base has_many :articles end
Then you call:
u = User.first
u.articles # => [some articles…]
u.articles # =>
ArgumentError: wrong number of arguments (2 for 1)
from …/activerecord/lib/active_record/associations/association_proxy.rb:78:in proxy_respond_to?' from .../activerecord/lib/active_record/associations/association_proxy.rb:78:in
respond_to?’
from …/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:155:in respond_to?' from .../activerecord/lib/active_record/associations.rb:1287:in
articles’
from (irb):3
As you can see, the bug is caused in the will_paginate plugin because it pass two params to the super respond_to?
def respond_to?(method, include_priv = false) #:nodoc: case method.to_sym when :paginate, :paginate_by_sql true else super(method.to_s.sub(/^paginate/, ‘find’), include_priv) end end
So the fix should be adding an extra param to proxy_respond_to?
def proxy_respond_to?(method, include_priv = false) super || @reflection.klass.respond_to?(method, include_priv) end
How could I test this to submit a patch?
PS: Even this is kinda curious because it throws the Exception after the second time it’s called, not the first one. Haven’t gone that deep yet.
Regards.
Edgar J. Suarez