Forum: Ruby on Rails Assign dynamic (incrementable) values to objects

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
mike (Guest)
on 2009-05-06 01:50
(Received via mailing list)
I am working on a registration form for users.
Users can sign up to attend some sport events and are automatically
assigned a starting number depending on the users type.

There are several types of users and all have a specific range of
starting numbers.

0001 - 0050: not automatically assigend
0051 - 0600: type 1
0601 - 0650: type 2
1000 - 1300: type 3

What would be the best practice, to assign these values to a user and
increment the right counter?

Storing these values in a database table might be a little tricky.
I also could save the configuration in a yaml file, load it from there
and write it back. But what about multiple reads and writes at the
same time. Can this be handled by a message queue, which ensures that
the file (or database table) is sequentially accessed?

Thanks for any comment!
This topic is locked and can not be replied to.