Re: [rubysur] Rails manejo decimal

27 views
Skip to first unread message

Pablo Barrios

unread,
May 23, 2013, 7:23:03 PM5/23/13
to rub...@googlegroups.com



2013/5/23 <luis.r...@xperience.cl>
Estimados,

   Recurro a ustedes para ver si me pueden orientar un poco:


 Tengo el siguiente problema, tengo una tabla que tiene los campos decimales con la siguiente descripción:

   t.decimal   "sofa_porcfact",       :precision => 10, :scale => 2
   t.decimal  "sofa_montofact",     :precision => 10, :scale => 2
   t.decimal  "coti_monto",              :precision => 10, :scale => 2


Tengo el archivo es.yml configurado de la siguiente manera:

"es":
 # Action View
 number:
   # Used in number_with_delimiter()
   # These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
   format:
     # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
     separator: "."
     # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
     delimiter: ","
     # Number of decimals, behind the separator (1 with a precision of 2 gives: 1.00)
     precision: 2
     # If set to true, precision will mean the number of significant digits instead
     # of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2)
     significant: false
     # If set, the zeros after the decimal separator will always be stripped (eg.: 1.200 will be 1.2)
     strip_insignificant_zeros: false

   # Used in number_to_currency()
   currency:
     format:
       # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
       format: "%u %n"
       unit: "$"
       # These three are to override number.format and are optional
       separator: "."
       delimiter: ","
       precision: 2
       significant: false
       strip_insignificant_zeros: false

Y el problema es el siguiente:

Si en un input text de la vista ingreso

1.2   guarda  => 12

Si ingreso 

1,2   guarda  => 1.2

Al momento de editar me muestra en el  input text 1.2 pero cuando hago submit lo guarda como 12.

Alguna sugerencia de que puedo hacer para solucionar este


Hola Luis,

Te aconsejaría que pruebes con una configuración similar a la que usa la gems rails-i18n


Espero te sirva saludos

Saludos 


--
Ing. Pablo G. Barrios
Reply all
Reply to author
Forward
0 new messages