0

We recently upgraded our Rails 4.2 application to Rails 5.0 (we'll upgrade to Rails 5.2 eventually).

With Rails 4.2 we were using UUID gem that we are not using with Rails 5.

Currently, the problem Rails 5/Postgres is that it generates in UUIDs with hyphens (sd5e1bcd-da49-43c6-bc87-381232e0101b). From Postgre perspective it treats UUIDs with and without hyphens equally. However, we have integration with the external applications where we refer UUIDs that have UUIDs without hyphens for existing records. For that, we need Rails to have UUIDs always without hyphens.

The question is, is it possible on Rails/PG gem level to always return the UUIDs without hyphens?

Thanks

2
  • UUIDs without hyphens - do you mean your app needs the UUID in decimal? itu.int/rec/T-REC-X.667-201210-I/en section 6.5.3 requires the dashes in the hex representation. Complain to the vendor of the other component and ask them to fix it to accept UUID. Commented Jun 13, 2018 at 0:49
  • Thanks for your note. The other app is our own :), but the problem is it's used on a lot of places, and it would be hard to reset them to with hyphenated version. I was just trying to find a general way to be consistent with MySQL/active_uuid version. Commented Jun 21, 2018 at 17:01

1 Answer 1

4

As per the description shared it seems like you will have to develop a custom logic for mapping UUID from db to the external applications.

Workaround for that would be:

uuid().replace(/-/g, '')

Note that the above mentioned solution have to be done at the application level.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the suggestion Rohan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.