I am trying to implement STI as follows
module ModuleName
class ParentName
self.inheritance_column = 'column_name'
end
end
module ModuleName
class ChildName < ModuleName::ParentName
class << self
def find_sti_class(type_name)
type_name = self.name
super
end
def sti_name
self.name.sub(/^.*:/,"")
end
end
end
When I try
ModuleName::ChildName.create(column_name: 'ChildName')
I am getting following error
ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: ChildName is not a subclass of ModuleName::ChildName
I was trying to refer to solution provided here Rails STI: How to change mapping between class name & value of the 'type' column
Any help appreciated. Thanks.