All threads / Polymorphic Selects in Rails using GlobalIDs Discussion
Ask A Question


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?

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

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

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?

Join the discussion

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

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

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

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.