Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with IPAddr (since 1.8.4) #1673

Closed
ledermann opened this issue Dec 12, 2024 · 1 comment · Fixed by #1675
Closed

Does not work with IPAddr (since 1.8.4) #1673

ledermann opened this issue Dec 12, 2024 · 1 comment · Fixed by #1675
Labels

Comments

@ledermann
Copy link

Expected behavior

Geocoder should handle instances of IPAddr (used for database columns with type inet) - like mentioned in #1513.

After upgrading to 1.8.4 this does not work anymore.
This regression was caused by fixing #1662 with 95eeaba.

Actual behavior

The sanitized_text method tries to call IPAddr#strip, which does not exist:
https://github.com/alexreisner/geocoder/blob/v1.8.4/lib/geocoder/query.rb#L26

Steps to reproduce

myapp(dev)> Geocoder::Query.new(IPAddr.new "1.1.1.1").sanitized_text
(myapp):8:in `<main>': undefined method `strip' for an instance of IPAddr (NoMethodError)

        text.strip
            ^^^^^^

This patch allows using 1.8.4 in my app:

IPAddr.class_eval do 
  delegate :strip, to: :to_s
end

Environment info

  • Geocoder version: 1.8.4
  • Rails version: 8
  • Database (if applicable):
  • Lookup (if applicable): ipdata_co
@alexreisner
Copy link
Owner

Thanks for this exemplary bug report. Seems like we should change that line to text.to_s.strip and add a test to make sure this doesn't happen again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants