Generating a random number

Hey guys,

Ok, so right now I am working on generating a random number with ruby
or rails?

So far I have gathered that I somehow or another want to use the
rand() helper to so, but not sure how to do it to achieve what I am
trying to accomplish.

What I am trying to do, is have a 6 digit number randomly generated,
and then tag it to a course name, for this
training portal I am writing. This is mostly so I can locate courses
in the mysql database without typing in the exact title.

Why do you want a random number? Why not just use the primary key
integer that Rails will give you for free? You don't have to do any
work to generate it and the only downside is that if I see /course/1 I
imagine I could try /course/2 and it would work, but if you're not
trying to "hide" these courses that shouldn't be an issue.

   @random = self.rand(99999), rand(9).to_s)

One problem with this is that you may end up with a duplicated value
sometime down the road. So you'll have to check for uniqueness even
when doing this.