문제

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