Skip to content

Instantly share code, notes, and snippets.

@jcohenho
Created January 13, 2016 00:25
Show Gist options
  • Save jcohenho/9ca3c55207e05e535ffc to your computer and use it in GitHub Desktop.
Save jcohenho/9ca3c55207e05e535ffc to your computer and use it in GitHub Desktop.
class Product
### attributes: product_name, uid
validates_uniqueness_of :uid
before_save :set_uid
private
def set_uid
self.uid = product_name + SecureRandom.hex
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment