I am new to rails, and am stuck with the following problem:
I need a persistent class variable (I think) for a human readable customer ID. The customer class is a subclass of a contact class in an Single Table Inheritance setup, so the database generated ID is not usefull as it is not linearly ascending.
I suppose I need a class variable or global variable to implement a kind of counter/id (it is not the count method as customers can be deleted). Am I correct? In this case the class variable needs to be saved somehow to the database, right?
I am a bit lost on
- how to save it
- when exactly to increment it: I have to override the new method, calling first super?
- how to load the value in case the application needs to be restarted at some point
.
Should I prefer a Multible Table Inheritence setup instead and use the database ID? That would be a pitty, as more than 90% of the fields in both classes are the same.