Why does Rails strip leading zeros when trying to save a numeric value in Active Record?
For instance:
self.dps_billing_id = "0000060010123363"
self.save!
actually saves 60010123363.
The column is just a standard string field in a PostgreSQL database:
t.string "dps_billing_id"
I need the leading zeros to be stored because my credit-card gateway requires them, but I also cannot simply append a few zeros to the result because the amount can change.
How do I stop Rails trimming the zeros?
It may be because your
dps_billing_idis of type integer, not string.In my Rails console: