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

ip geocoding: general question #126

Closed
knzudgt opened this issue Aug 4, 2017 · 2 comments
Closed

ip geocoding: general question #126

knzudgt opened this issue Aug 4, 2017 · 2 comments

Comments

@knzudgt
Copy link

knzudgt commented Aug 4, 2017

My Rails 5 application needs to offer to users different pages according to the country of the users. I would also need geocoding in controllers. I wonder how can I get the country with geokit-rails: would the following code be correct?

country = IpGeocoder.geocode(request.remote_ip).country

Also: is there any maximum quota that the below quota has to respect?
I do not understand if geokit-rails relies on external geocoding services like google, bind or maxmind.

@mnoack
Copy link
Member

mnoack commented Aug 6, 2017

@knzudgt - You shouldn't need to do anything (I don't actually use this feature, I just took over maintaining this gem)

See the IP related section of the readme:
https://github.com/geokit/geokit-rails#ip-geocoding-helper

If you want to do this yourself (as your code sample is doing), you don't need the geokit-rails gem, the code could be done with just the geokit gem by itself.

@ryankopf
Copy link
Member

ryankopf commented Jan 3, 2021

Like @mnoack said, @knzudgt The geokit-rails gem is best used for adding geolocation features to your models. For example, if you have a "User" model, the user could have a lat and lng and you can find users that are near each other by calling something like User.by_distance(origin: @some_user)

If you just want plain 'ol geocoding features not specifically integrated in your models, you should just use the geokit gem, which is different from this geokit-rails gem.

As far as external services, any geocoding solution will require a third-party service unless it comes with download files. There are some services that offer free ip_address to country mappings that you can download and reference.

What CAN be done with geokit-rails without a third party solution is searching for records by distance using latitude and longitude values you've already saved in your database.

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

No branches or pull requests

3 participants