Rescue star for spelling mistakes in Ruby programming: did_you_mean gem
I often encounter spelling errors in Ruby development when class names or method names are misspelled. But I don't know it's just a spelling mistake. I will repeat it:
"It's so strange. It looks okay ..." |
I often waste a lot of time on this kind of thing, but the reason may be that a character is wrong. I hate such a thing.
That's why I developed did_you_mean gem. When you encounter NoMethodError or NameError, it will automatically find the correct method you really want to call and tell you.
gem 'did_you_mean', group: [:development, :test]
So what will happen when Hash # with_indifferent_access in ActiveSupport is misspelled? :
hash.with_inddiferent_access
# => NoMethodError: undefined method `with_inddiferent_access' for {}:Hash
#
# Did you mean? #with_indifferent_access
#
See it! Now, you only need to copy/paste the correct name indicated by 'did _ you_mean ', and the program will not be wrong.
Did_you_mean gem automatically displays the information it has tested in the error message. That is, "Did you mean ?" Gem will serve you anywhere. The following is a typical example of an error message in a real project:
You can find more examples on the GitHub project homepage: yuki24/did_you_mean
Use did_you_mean gem. Ruby will understand your thoughts.