You’re not receiving notifications from this thread.
Screencast requests: Global ID and @mentions
After watching the recent screencast on Action Text and @mentions, I became curious as to how Rails stores references to these associations in texts. Turns out it uses something called Global ID:
This might be an interesting topic for a future screencast.
Let's say you're building a Twitter-like app and want to support @mentions in the tweets. However, unlike Twitter you actually want the mentions to remain working after a mentioned user changes their username. We don't need the full rich text feature set, but similarly to Action Text we would store the actual user ID (or more specifically the Global ID) and render out the correct username whenever the tweet is shown.
We could create an additional Mention record as well, so we have an easy way to query in which tweets a particular user was mentioned
What do you think? I think the current @mentions screencasts are nice, but rather restricted in real-world applicability. I've been looking for a good approach and Global ID seems like the way to go.
Not sure if you missed it in the episode but thats exactly how ActionText works. It uses signed global IDs to load models and it does all that automatically for you so theres nothing you need to build.
To query, you would probably need to make an adjustment since the signed global id does not have a readable value stored in the db. May just want to add a join table between the models and add references during save.
I watched the episode, but the Global ID stuff all happens behind the scenes. I figured it would be interesting to take a closer look at how it works so we can implement something similar in situations where ActionText is overkill.