This project is archived and is in readonly mode.
text_field eating leading zero strings
-
Frederick Cheung
That's weird - I tried this on edge and 2.2.2 and it seem to work fine. What version of rails were you using.
-
Gravis
Hi,
I'm using rails 2.2.2, and the site has been migrated several time from 1.X.
The column type is a string, in schema.rb :
t.string "postal_code"and the problem occurs using sqlite and mysql.
Thanks
-
Gravis
can't reproduce problem on a fresh 2.2.2 app.
Okkkk, really sorry, my fault, the field was indeed an integer, and not a string (we have 2 postal codes there).
We can close the ticket, and really sorry for the time spend :(
-
Yehuda Katz (wycats)
- State changed from new to invalid
Gravis: no need to apologize! Is there anything we can do in documentation to reduce the possibility of someone else experiencing this same issue?
-
Gravis
Thanks Yehuda !
I think just a little paragraph in the guides explain that fields with possible leading zeros like postal codes, phone numbers, etc should be stored as string (with a :limit if possible). Also, It's generally a good idea to store this large "numbers" in a string field, since we generally don't do any calculation on them, nor number comparison ("postal code > value" ?). I'll try to add some lines in the rails guides regarding that.
Thanks Gravis (hope this post won't re-open the ticket !)