Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

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

Rails • Asked by William Gillett

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 => and

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.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.