Rescue star for spelling mistakes in Ruby programming: did_you_mean gem

Source: Internet
Author: User

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.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.