How to generate a unique random id for post in Ruby on Rails 4?
问题 I want to produce unique post identifier for posts in my blogging application. Currently I am using SecureRandom.hex(10) for generating unique post identifier for my blogging site but I am not sure is it safe SecureRandom for this purpose. Is there any other way to do this? 回答1: From the Ruby doc: This library is an interface for secure random number generator which is suitable for generating session key in HTTP cookies, etc. I had similar problem, I used Digest library. Digest::MD5.hexdigest