zabumba
zabumba

Reputation: 12422

Store Currency code along with price

I am storing a price in my database.

I figured I should store the currency as my application with need to support internationalisation.

I believe the correct way is to store the ISO 4217 currency code, such as USD for US$, AUD for AU$ and EUR for Euros ...

I have a price and a currency attribute in model... Am I doing it right?

How do convert the currency code to it Symbol version? is there a helper for this? do I need to create myself a corresponding hash?

Cheers,

Joel

Upvotes: 1

Views: 2026

Answers (1)

jdc
jdc

Reputation: 743

You should have a look at the Money gem. Handles currency codes and has support for exchange rates and formatting.

https://github.com/RubyMoney/money

Upvotes: 3

Related Questions