I have a simple blog app that lets me create an entry with title and a
body... real simple.
In addition to the id that the database creates by default per each
entry I would love to associate an unique id that uses
0123456789 and the 26 letters of the English alphabet.
So that means I have 36^7 unique ids right? assuming I want to keep
each unique combination no bigger than 7 digits, Why? This is
hypothetical.
Can anyone help point me into the right direction?
the intended result would be 00001, 00002, 00003 etc etc.
I was thinking to using a foor loop but a friend said that was a bad
idea.
A newbie here, I guess i dont have to point that out, anyone that can
help me will be great.
Thanks
Oliver.
I have a simple blog app that lets me create an entry with title and a
body... real simple.
In addition to the id that the database creates by default per each
entry I would love to associate an unique id that uses
0123456789 and the 26 letters of the English alphabet.
So that means I have 36^7 unique ids right? assuming I want to keep
each unique combination no bigger than 7 digits, Why? This is
hypothetical.
Can anyone help point me into the right direction?
the intended result would be 00001, 00002, 00003 etc etc.
I was thinking to using a foor loop but a friend said that was a bad
idea.
A newbie here, I guess i dont have to point that out, anyone that can
help me will be great.
Thanks
the intended result would be 00001, 00002, 00003 etc etc.
I was thinking to using a foor loop but a friend said that was a bad
idea.
A newbie here, I guess i dont have to point that out, anyone that can
help me will be great.
Thanks
irb(main):006:0> 50.to_s(36)
=> "1e"
That works really well. If you'd like something more sophisticated, you
could implement Doug Crockford's base-32 algorithm described at
Base 32 . I've got some code for that
algorithm at
http://groups.google.com/group/techvalleyrb/msg/ac3ce4ae6620268a that I
probably should put into a gem...