Feature #8062

Argument error stack trace to specify the 'called' method

Added by randoum (Benj Benj) over 4 years ago. Updated over 4 years ago.

Target version:


Feature request about the stack trace generated by Ruby, the step by step bellow is using Rails, but if I'm not wrong this is Ruby related.

When an ArgumentError exception is raised, the stack trace should display the 'called' method, it actually display only the 'caller' method. This would be great help for debugging

Background for the step by step
Rails define a method named 'fields_for' in module ActionView::Helpers::FormHelper, I'll be writing my step by step depending on that but it should be possible to reproduce in any similar situation

Step by step
1- Create a module called 'MyModule' and create a method called 'fields_for'

2- In an view, write do code with the following statement 'form_for @mymodel { |f| f.submit }'

3- Execute the code, and see that the top line of the stack trace after the exception is raised is:
(gem) actionpack-3.2.12/lib/action_view/helpers/form_helper.rb:378:in `form_for'

This is actually the line in Rails module that perform the call to the method 'fields_for'
But there is no way to understand that Ruby trying to call the method from my module instead of the method from Rails module
A good solution would be to display the name and position of the 'called' method in the stack trace, so the last line of the stack trace would clearly indicate that we have a naming conflict

ruby-v: (gem) actionpack-3.2.12/lib/action_view/helpers/form_helper.rb:378:in `form_for'

Sorry if it looks confuse, I can't find a better way to explain it, I hope you guys got the picture

Many thanks for your time


#1 [ruby-core:53281] Updated by randoum (Benj Benj) over 4 years ago

(sorry I just realized my CTRL+C bug sometimes)
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [i686-linux]

#2 [ruby-core:55234] Updated by zzak (Zachary Scott) over 4 years ago

  • Status changed from Open to Feedback
  • Target version set to next minor

Can you provide a plain ruby example? And include the output you'd expect?

Also available in: Atom PDF