Skip to content

Instantly share code, notes, and snippets.

@acallaghan
Created March 18, 2013 12:15
Show Gist options
  • Save acallaghan/5186765 to your computer and use it in GitHub Desktop.
Save acallaghan/5186765 to your computer and use it in GitHub Desktop.
Generate a random hex string for primary key, rather than integer
private
def generate_unique_id
self[self.class.primary_key] ||= ActiveSupport::SecureRandom.hex(5).downcase
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment