How can I reflect on a method which had been extended into an
association.
If i try model.association.method(:method_name) I get an undefined
error yet I can invoke it via model.association.method_name. I've
tried several different approaches to get at the method but can't seem
to be able to get hold of it.
class Post
has_many :comments do
def some_method
end
end
end
The basic issues is that post.comments is not an array, it's an instance of a proxy class that will (when needed) load the collection and forward methods.
so when you call post.comments.method(:some_method) that's being forwarded on to the array itself.
You can use post.comments.proxy_respond_to?(:foo) to find if the proxy itself response to a method, but the 'method' method has been undef'd on association proxies.