Save time and currency for the user

We want to allow users to save time zone and currency preferences in user settings.

We use Rails 4 and MongoDB with MongoID. Is there any GEM that allows us to do this?

What type of data is best suited for storing it, since all the time on the displayed site you need to convert to the required time zone.

+4
source share
1 answer

If you use Rails time zones , you will save the identifier associated with this time zone. For example, Eastern Time (US and Canada). However, I do not recommend using Rails time zones for the reasons stated in the time zone quiz (below).

Instead, you should probably use tzinfo gem , which uses standardized time zones from IANA / Olson data. For example, "America / New_York."

A currency is best stored as a three-letter ISO 4217 currency code . For example, "USD" or "EUR".

+9
source

Source: https://habr.com/ru/post/1524806/


All Articles