I'm thinking of a way to handle dynamic pricing on my web app based on the user country, for example:
A user wants to subscribe for a pro account on my website and this user is based outside the US so that user don't need to pay VAT... So the price for the subscription to my site changes for those users.
How can I handle this more effectively? I was thinking that it's all about the user ip address and then use ruby geocoder.
You could definitely geocode their IP in order to get their country. That would probably be the most accurate version of this. Alternatively you could ask the user to fill out their country as part of the sign up process or something in order to record that without doing geocoding. The geocoding approach will look a lot more seamless on the UI side of things though, so I'd probably recommend that route.
Another option I just thought of could be taking the locale from the browser and using that to determine the country: http://stackoverflow.com/questions/7113736/detect-browser-language-in-rails I'm not sure how well this would work as the geocoded IPs would definitely be more accurate.
Yeah I'm going to use the Geocoder gem as well as the built-in ip getter from Devise to accomplish that.
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.