Ask A Question

Notifications

You’re not receiving notifications from this thread.

Polymorphic Selects in Rails using GlobalIDs Discussion

This is fantastic Chris thank you, I'm curious how this would work for the edit view of the form?

Reply

You'll need to set the expires_in: nil parameter to have idempotent signed ids generated.
Document.find(5).to_sgid(expires_in: nil)

Documented here https://github.com/rails/globalid

This way your browser will be able to display the currently selected value from the list of options.

Reply

Chris, I usually don’t want to leak IDs so I use uuid columns for that, and also change to_param to return the uuid. Do you also think this is a suitable replacement for that use case?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.