logo       

[Rails I18n] Locale Currency - final run: msg#00006

lang.ruby.rails.i18n

Subject: [Rails I18n] 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 =
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
_______________________________________________
Railsi18n-discussion mailing list
Railsi18n-discussion@xxxxxxxxxxxxx
http://rubyforge.org/mailman/listinfo/railsi18n-discussion
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise