Zipcode , to_i and leading zero in Ruby/Rails

后端 未结 3 755
旧巷少年郎
旧巷少年郎 2021-01-14 13:14

I am trying to save zip codes which are passed in the params as \"07306\", and \"03452\", but to_i seems to be converting these string

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 13:58

    Saving it as a string instead will alleviate that issue, and also would help future-proof things if you decide to support foreign ZIP codes which may or may not have letters in them.

提交回复
热议问题