ruby - Best way to generate order numbers for an online store? -


Every order in my online store has a user-chain order number, I am thinking of the best way to generate them.

  • Easy to say on the phone (like "m" and "n" are unclear)
  • Unique

  • Li>

    I'm currently using the following method (no checksum):

      Generate DRF_name possible_value = 'abfhijlqrstuxy'.upcase.split (' ') | '123456789'.split (' ') record = true while the record is random = Array.new (5) {possible_values ​​[rand (possible_values.size)}}. Enter the record = order.find (: first,: conditions => ["number =?", Random]) end self.number = random end  
  • < For example:

    P> For example:

      2009-07-27 / kt1e  

    This gives approximately 33 ^ 4 ~ 1 MLL order for the day .


    Comments

    Popular posts from this blog

    c# - ListView onScroll event -

    PHP - get image from byte array -

    Linux Terminal Problem with Non-Canonical Terminal I/O app -