Create A Custom Prefix On A UUID
I would like to know if there is any way to create a custom prefix on UUID's in rails. I would like to generate something like:
I found this code, which I can add to my migration to create the UUID:
t.uuid "uuid", default: "uuid_generate_v4()"
But this would generate something like:
Is it possible to get the format that I want?
As mentioned in comments, postgres defines the UUID as (https://www.postgresql.org/docs/9.1/static/datatype-uuid.html)
A sequence of lower-case hexadecimal digits, in several groups separated by hyphens, specifically a group of 8 digits followed by three groups of 4 digits followed by a group of 12 digits, for a total of 32 digits representing the 128 bits
So you can't prefix
ret_ in UUID column. Also you shouldn't, if you want to identify retailer and customer create another column for it.
SqlFiddle when concatenated UUID is used. It'll throw an error.
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?