On Jun 7, 8:11 am, “Isak H.” [email protected] wrote:
I’m working on a rake task that loads AR models from a yaml file,
which fails when I try to use a deserialized object, as its class
hasn’t been loaded.
I don’t know beforehand exactly which classes are in the file(s), so
need a way to load them dynamically, or load all the model classes.
I’m not sure this is the preferred way, but if you load config/
environment.rb you will have access to (among other things) all of
your models. So, for example, assuming your task was defined in lib/
tasks/somefile.rake you could call require thusly:
require File.expand_path(File.dirname(FILE) + ‘…/…/…/config/