I have never used STI with AR but I am now considering it. My question has to do with the
Base.inheritance_column
. According to the api docs:
Active Record allows inheritance by storing the name of the class in a column that by default is named “type” (can be changed by overwriting
Base.inheritance_column
). class Transaction < ActiveRecord::Base end class ArClientInvoice < Transaction end
``
Can one assign a value within the subclass to use in the `inheritance_column in place of the class name? For example, given:
Is there any way to arbitrarily set ArClientInvoice.type to “ARIN” for all occurrences and to have Active record use this for STI purposes in place of “``ar_client_invoice”? The use case for this is for compatibility with a non-Rails application.
The simple answer is to rename the class to ` ARIN < ActiveRecord::Base
``