diff options
author | Mike Ferrier <mferrier@mikebook-pro.local> | 2008-12-04 13:31:18 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-12-04 13:31:18 -0600 |
commit | 566a3dce6753eb71554d54e8883204e4868aa393 (patch) | |
tree | ed55713b5f5e8e809d50ff5d4abdf3b24ff9271e /activerecord/lib | |
parent | b2ad3029cd0d4f45c2db283f8246d3dbf9078e5f (diff) | |
download | rails-566a3dce6753eb71554d54e8883204e4868aa393.tar.gz rails-566a3dce6753eb71554d54e8883204e4868aa393.tar.bz2 rails-566a3dce6753eb71554d54e8883204e4868aa393.zip |
Make NoMethodError message more descriptive when an undefined message has been sent to an association [#1515 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/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 75ec4fbb2e..59f1d3b867 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) } |