So, this may sound kind of “whacky”, but I’m trying to figure out a way
to populate an ActiveRecord object using YAML instead of a DB table.
I’m not even sure if this is actually feasible, but it sounds like a
good way to increase the performance of a project I’m working on.
For instance, I have a model called CmsModules that contains information
about the sections in a CMS. Modules are only added during development,
so the table will never be updated while in production. The way things
are currently set up, an SQL statement is executed on every page load in
order to grab that information. I figure this is unnecessary, and I’d
like to keep the same functionality without making those extra calls to
the database.
I figure that I could use a YAML file to store the module information,
therefore eliminating the need to access the database. Easy enough to
do using YAML::load, but the problem is that I need to keep a HABTM
relationship to the User model intact for access control. That’s where
I’m lost…
So, my question is this - is there any way to have legit ActiveRecord
objects populated from a YAML file, completely bypassing the database?