We want to allow users to store their preference of Time Zone and Currency in the User settings.

We are using Rails 4 and MongoDB with MongoID. Is there any GEM that allows us to do it?

What datatype is best suited for storing them as all the time across the site displayed will have to be converted into the required timezone.

有帮助吗?

解决方案

If you're using Rails time zones, then you would store the identifier associated with that time zone. For example "Eastern Time (US & Canada)". However, I don't recommend that you use Rails time zones, for the reasons outlined in the timezone tag wiki (near the bottom).

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top