I’m dealing with an error that I have been yet unable to debug. I had an application with 100% green tests in Rails 6.0. I tried updating the app to Rails 6.1 and now I’m seeing the following behaviour:
include ActionView::Helpers::NumberHelper
number_to_currency 7
TypeError (no implicit conversion of String into Integer)
Ruby 2.7.3 Rails 6.1
There are a lot of gems and I’m wondering if this is related to somebody monkey-patching something but I don’t know if there’s a way to trace a source of the money patching? Or if you have any ideas I would appreciate any advice.
Here’s the backtrace:
number_to_currency 7
NoMethodError: undefined method `nan?' for nil:NilClass
5 module ActiveSupport
6 module NumberHelper
7 class NumberToRoundedConverter < NumberConverter # :nodoc:
11 def convert
24 if precision = options[:precision]
31 formatted_string =
❯ 32 if rounded_number.nan? || rounded_number.infinite? || rounded_number == rounded_number.to_i
34 else
40 end
41 else
47 end
62 end
63 end
64 end
By using the
pry-railsgem, you can most likely find the source by putting inbinding.pryjust above where the error occurs, and then re-running the code. When the Pry REPL comes up, you can then run the commandshow-source number_to_currency. This will show you the file location, for example:If you then need to go up the definition chain, you can also use the
--superflag multiple times to go up until you find the issue. For example, to go up 2 supers, you would doshow-source --super --super number_to_currencyYou can see more options with
show-source --help