Interesting problem create unique integer from an alpha-numberic string

10 views
Skip to first unread message

Mark Locklear

unread,
May 30, 2013, 10:53:12 AM5/30/13
to ashevi...@googlegroups.com
Hey folks! I have an issue where I am seeding a database, and I need to set the primary key id's of the data. The seed data contains ID's, and I need to set those ID's as my primary keys in my Rails DB. The issue I have having is that the primary keys in the seeded data are alpha-numberic. Rails needs its primary keys to be integers. I am thinking there has to be some clever way to convert a alpha-numeric string to a unique integer? It can't be random though...something equivalent to the decoder ring in your cracker jacks.

--
J. Mark Locklear
-Philippians 4:13 gives you the muscle, but YOU have to flex it!

"One machine can do the work of fifty ordinary persons. No machine can do the work of one extraordinary individual."
-- Elbert Hubbard

Mark L.

unread,
May 30, 2013, 11:41:53 AM5/30/13
to ashevi...@googlegroups.com
So I ended up using to_i(36) on the string which seems to work like a charm.
Reply all
Reply to author
Forward
0 new messages