# Locale Currency - final run

**URL:** <https://www.ruby-forum.com/t/locale-currency-final-run/96919>\
**Category:** Rails I18n\
**Created:** [July 3, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/locale-currency-final-run/96919 "2006-07-03T14:31:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 3, 2006, 2:31pm UTC](https://www.ruby-forum.com/t/locale-currency-final-run/96919/1 "2006-07-03T14:31:14Z")

</div>

As Currency.parse(@localprice) can only work with us formatted  
string (as stated by u Josh)  
I transformed my locale strings into a us one before sending it to  
parse :

@p1 = @localprice.tr".,",",." =\> “125.256,25 â?¬” -\>  
“125,256.25 â?¬”  
@product.price = Currency.parse(@p1) =\> @product.price.cents =  
12525625

and it works ( I get the correct @cents ready to be stored…)  
but then executing (either runtime or breakpoint)

@product.save

RuntimeError: can only compare with money or integer  
./script/…/config/…/vendor/plugins/trunk/lib/globalize/models/  
currency.rb:64:in `<=>' script/../config/../app/models/product.rb:29:in`validate’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/  
active\_record/validations.rb:753:in `valid_without_callbacks' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/ active_record/callbacks.rb:306:in`valid?’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/  
active\_record/validations.rb:723:in `save\_without\_transactions’  
…

strange , @cents is an Integer type… and price in my DB too…

what else am I missing ?

kad
