Locale Currency - final run

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 =

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


RuntimeError: can only compare with money or integer
currency.rb:64:in <=>' script/../config/../app/models/product.rb:29:invalidate’
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:invalid?’
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 ?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs