Reputation: 5355
I am seeding a database in Rails. The seed data contain ID's, and I need to set those ID's as my primary keys. The primary keys in the seeded data are alpha-numeric. Rails needs its primary keys to be integers. I am thinking there has to be some way to convert an alpha-numeric string to a unique integer. It can't be random. Something equivalent to the decoder ring in your cracker jacks.
Upvotes: 1
Views: 1983
Reputation: 168239
If you do not need to distinguish upper and lower cases, then for example,
"fkfj23".to_i(36) # => 941309499
Upvotes: 6