From 8ce31332cae7f5d7b43c89c461711af17ebbb82f Mon Sep 17 00:00:00 2001 From: Mike Ferrier Date: Thu, 4 Dec 2008 13:42:31 -0500 Subject: [PATCH] Make NoMethodError message more descriptive when an undefined message has been sent to an association. --- .../associations/association_proxy.rb | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 75ec4fb..59f1d3b 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -207,7 +207,10 @@ module ActiveRecord # 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) } -- 1.6.0.2