diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 75ec4fbb2ec0a..59f1d3b867997 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -207,7 +207,10 @@ def with_scope(*args, &block) # Forwards any missing method call to the \target. def method_missing(method, *args) if load_target - raise NoMethodError unless @target.respond_to?(method) + unless @target.respond_to?(method) + message = "undefined method `#{method.to_s}' for \"#{@target}\":#{@target.class.to_s}" + raise NoMethodError, message + end if block_given? @target.send(method, *args) { |*block_args| yield(*block_args) }