I want to find a users time zone from his ip address. If the user is travelling the application should be able to find out the current time zone in which he is.
You can't, at least reliably: think of proxies, ISP NAT or VPNs, even if a user seems in a country it doesn't mean he's really there.
I would suggest to let the user choose his preferred time zone, and let him alter it if he needs to.
Otherwise, have a look at this: Determine a User's Timezone
Yes, you can get the timezone in rails based on the user's IP address but it won't be accurate always because of proxies or VPNs.
Why?
However, if you have a chance to overlook this shortcoming you can use check this gem with the IP lookup service. To test, you can use the ipapi_com service(it is free up to 45/minute). For the implementation hints, you can have a look here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With