The Sweet Spot
On software development, engineering leadership, machine learning and all things shiny.

Ohm gotchas

Here’s a list of things that have been annoying, or at least a bit frustrating using Ohm, the Redis ORM, in a Rails app. Beware to those who assume Ohm is ActiveRecord in new clothes. It is, but it’s not:

CRUD

Don’t make the mistake of treating your Ohm objects like AR:

ActiveRecord Ohm
destroy | delete`  
self.find(id) self[id]
update_attributes update
create create

Also note that Ohm’s update_attributes behaves differently from Rails` – it doesn’t persist the updates to DB. That owned me for the good part of the day.

Callbacks

Thankfully, these are ActiveRecord-like with the addition of ohm/contrib.

Associations

ActiveRecord Ohm
has_a or belongs_to reference
has_many collection

Read this article if you’re considering creating associations from AR objects to Ohm objects and the other way ‘round.

Liking what you read?

Accelerate your engineering leadership by receiving my monthly newsletter!

    At most 1 email a month. Unsubscribe at any time.