Topic: Fixed Length Random Integer

Hi Guys

I did an hour of google searching on this, and could not find anything. How do I generate a random number of fixed length in Ruby on Rails ? random numbers such as:

12324, 76889, 44323, 10973, 33200

all are of length 5, but are random.

I would greatly appreciate any help.

Thank You.

"Facts do not cease to exist because they are ignored." .... Writer Aldous Huxley (1894 - 1963)

Re: Fixed Length Random Integer

You can use ruby to create the random numbers, see below:

rand(99999).to_s.center(5, rand(9).to_s) - from this post here

if you put that into tryruby.org you will get a random number with a fixed length of 5.

Also, the framework is "Ruby on Rails/Rails". Ruby is the actual programming language.