Category

Uncategorized

Global IDs in Rails

I recently learned about Global IDs in Rails applications.

Just as a reference, the link to the Global ID repo is https://github.com/rails/globalid.

That GitHub repo does a good job of explaining what Global ID is but TLDR version is that it’s a global identifier that you can use to locate an instance of a model.

I found it to be pretty useful when passing in ids of various model instances in a job queue. For example, let’s say that you have a few models with one model having a belongs_to polymorphic association with the rest of the models. You create a record of this polymorphic model in a job class. Let’s have an example here.

In the PictureCreatorJob, thanks to us using the global_id of the user, we can locate the model without having to conditionally check which model we should be querying with ActiveRecord. I find that in these specific situations, Global ID can make your code more succinct and concise.

MaterialReads Android app released

I released my first solo Android app on the Google Play Store.

It’s an Android client for Goodreads website.

You can download it here. I built it mostly for the sake of finishing a project. The goal is to slowly add features, bugs, and performance enhancements to increase downloads counts and see where I can take it from here.