I'm interested in learning what folks in the Rails community do when
they need to
generate permanent unique numbers for tracking objects such as packing
slips, inventory items, customers, employees, etc.
It's tempting to use the autogenerated id, but they're not pretty
enough for human consumption and it can be problematic having assigned
ids if tables ever need to be reogranized.
I think it would be preferrable to use a sequence, but haven't found a
way of doing this with MySQL, so I just increment the max value of the
id column. Here's how I generate a customer number:
CUSTOMER_BASE = "10000"
def next_id(table_name, column)
@customer.number = CUSTOMER_BASE.to_i + next_id('customers',
Have I simply postponed the problem to the day when ids have been
re-organized beyond the customer_base and I start generating
So what do you do?? I'm all ears...