Hey list,
My employers (and I) develop an application that is deployed for many different businesses, and whilst we provide our functionality as a service hosted on our own servers, we are still required to integrated with their existing systems. This is starting to become a problem, as our generic model doesn’t quite fit nicely with all of our customers and consequentially some minor hackery has ensued.
I’m looking into the possibility/feasibility of dynamically loading models based on runtime conditions. I’m just wondering if anyone else has done something similar? To be a little more specific, I imagine we’d need a database table per customer (plus a default) and then a model that is dynamically loaded in such a way that references to it throughout the existing code remains the same. E.g:
class MyFoo < AR end
class CustomerAMyFoo < AR include MyFooHelper end
class CustomerBMyFoo < AR include MyFooHelper end
All code, expect that contained in MyFoo, should not know that CustomerAMyFoo and CustomerBMyFoo exist. I imagine MyFoo would act as a simple proxy using some method_missing magic. That’s one approach, though I’m not particularly keen on it. Does another solution exist that doesn’t involve a proxy but without the overhead of reloading the module on each request?
Cheers Ian