Permalink
Browse files

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>
  • Loading branch information...
1 parent b2ad302 commit 566a3dce6753eb71554d54e8883204e4868aa393 Mike Ferrier committed with josh Dec 4, 2008
Showing with 4 additions and 1 deletion.
  1. +4 −1 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) }

0 comments on commit 566a3dc

Please sign in to comment.