How can I generate a random variable of letters and numbers, such as the
ones used by many websites where a random variable is used in the url in
order to activate an account.
Thanks!
How can I generate a random variable of letters and numbers, such as the
ones used by many websites where a random variable is used in the url in
order to activate an account.
Thanks!
Cheri wrote:
How can I generate a random variable of letters and numbers, such as the
ones used by many websites where a random variable is used in the url in
order to activate an account.Thanks!
There’s a couple of different ways. It can also depend on if you want
either a one-time throwaway value or something you can recompute given
certain data.
Say you wanted one based on an email address and a username, you could
just return a computed string based on a digest of the values; if you
have the Pickaxe book, the Digest library entry should help you with
what you need.
As far as one that’s completely random, a simple loop should do the
trick.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs