Save 36% for Black Friday! Learn more

New Discussion

Notifications

You’re not receiving notifications from this thread.

What is the best way to determine the country/currency for a user?

1
Rails

I am using a similar set-up as gorails - devise for registration and stripe for subscriptions. I have separate plans for each currency were are going to market to (USD, CAD, GBP). But I want to offer up the subscription options to the user in their currency - what is the best way to do this short of asking them - what country do you live in? I would like to make an intelligent guess and then allow them to change it if needed.

Check out the Geocoder gem => https://github.com/alexreisner/geocoder and http://stackoverflow.com/questions/34816490/get-remote-ip-address-in-rails-model

What you'll want to do is snag the IP in the controller with something like
@request_ip = request.ip then geocode @request_ip for the country.

You can really use just about any geocoding service that can do the ip address to physical address conversion.

Join the discussion
Create an account Log in