All threads / How can you allow users (companies) in your app to select their own currency?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How can you allow users (companies) in your app to select their own currency?

Viktor Smári asked in General

We use i18n and we have our app in ~5 languages, but we want the companies to be able to select which currency to use.
Mainly to choose the correct symbol to show on their invoices to their customers.
This is not an e-commerce site, so no currency conversion is needed, only displaying of currency.

Requirements:

  • In company settings, there would be box with all the available currencies from i18n or similar
  • A company in Netherlands can have the app in English but choose the Euro currency.
  • A company in Argentina can have the app in Spanish but use the Argentine peso (and not the Euro)

We have done extensive research and found no clear answer to this. Maybe the answer is too obvious and we missed it?

Related unanswered questions:
https://stackoverflow.com/questions/16285677/multiple-currencies-in-rails
https://stackoverflow.com/questions/36700004/ruby-on-rails-currency-switcher-for-whole-site
https://stackoverflow.com/questions/58357673/how-to-allow-users-to-select-all-currencies-but-with-limited-languages
https://www.reddit.com/r/rails/comments/gepybq/how_do_you_allow_users_to_select_between_multiple/
https://github.com/svenfuchs/rails-i18n/issues/874

You could add a currency field to your Company model, and allow it do be modified through the CompaniesController#edit action. This way I can have my locale as Spanish, but select any currency that I want and see that across the application.

  1. How do you generate your list of currencies? Do you use the money gem?
  2. How do you display the currency format, which helper do you use, if any?
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 48,387+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.