In memory ActiveRecord-alikes?


#1

Say that I have such a small amount of data that I’m fine with just
coding it directly into Ruby in a hash or something. But I still want
to treat it like a model – in particular, I have another object that
has_one of these things. Can I do that? When my primary object loads,
how to I tell it not to generate SQL to go find the secondary object,
but just to use what the object already has?

Does the question even make sense? Or is this very bad practice and I
should find another way?


#2

I just don’t inherit from ActiveRecord. There’s probably a more elegant
way, but for the limited things I’ve needed this has worked just fine.
method_missing is your friend here for just catching things you don’t
care
about.

  • James M.