I have a set up where I have multiple models inheriting from a Base model - standard Single Table Inheritance:
class Parent < ActiveRecord::Base
end
class A < Parent
end
class B < Parent
end
My STI setup is correct and works great! However, I want to add :type specific attributes such as description.
For example, I want all A types of Parent to have the description, "I am the A type of Parent. My function is for..."
I want to avoid replicating data over and over (having each instance of A store the same description for example).
The first thing that came to mind for this was to have a model specific method on the Subclass. So something like:
class A < Parent
def self.description
"I am the A type of Parent. My function is for..."
end
end
I don't like this solution because this really is data on the specific type of subclass (rather than on the subclass instance itself) and you get all the problems that come with making this behavior (deployments to change data, etc.)
Is this the only way to do it or are there alternatives I just am not seeing?