I know that we shouldn't make database calls in the Initializer, but how
do we avoid this when a class 'bootstraps' itself when it is required,
class Status < ActiveRecord::Base
# Add constants representing the various status
SUBMITTED = self.find(...)
APPROVED = self.find(...)
DENIED = self.find(...)
I have, in my initialization block, a line which causes some model
classes to be 'required', e.g.
config.active_record.observers = :audit_observer # 'requires' observed
My problem is that the initialization block runs while executing
migrations, and therefore fails on a migration from version 0, because
the Status table doesn't yet exist.
I've tried config.after_initialize, with no luck. Is there some other
way to do initialization only after the migrations have run?