10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/inheritance_integer_type/extensions.rb', line 10
def find_sti_class(type_name)
lookup = self._inheritance_mapping[type_name.to_i]
if lookup
if ActiveRecord::VERSION::MAJOR < 5
super(lookup)
else
begin
if store_full_sti_class
ActiveSupport::Dependencies.constantize(lookup)
else
compute_type(lookup)
end
rescue NameError
raise SubclassNotFound,
"The single-table inheritance mechanism failed to locate the subclass: '#{type_name}'. " +
"This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
"Please rename this column if you didn't intend it to be used for storing the inheritance class " +
"or overwrite #{name}.inheritance_column to use another column for that information."
end
end
else
super
end
end
|