Question

I'm using the money-rails gem to parse currencies, however it's not parsing the currency symbol as otherwise specified in the documentation (http://rubydoc.info/gems/money/frames).

I get this, when trying to parse:

1.9.3p484 :011 > "£20.00".to_money
 => #<Money fractional:2000 currency:USD> 

It doesn't recognize the "£"-symbol as GBP.

What am I doing wrong?

Was it helpful?

Solution

Is it supposed to recognize the symbol? Maybe you're not setting

Money.assume_from_symbol = true

From the docs examples:

# Assumptive Currencies
Money.assume_from_symbol = true
Money.parse("$100") == Money.new(10000, "USD")
Money.parse("€100") == Money.new(10000, "EUR")
Money.parse("£100") == Money.new(10000, "GBP")

(Maybe it works with String.to_money too)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top