module DynamicModelActiveRecordExtensions::ClassMethods

Public Instance Methods

sti_model?() click to toggle source

if this class has a type attribute, then it is a model which is using single table inheritance if it is the base class for STI, its parent will be ActiveRecord::Base – if using AR.

# File lib/dynamic_model_active_record_extensions.rb, line 21
def sti_model?
  return false if sti_parent_class == ActiveRecord::Base
  attribute_names.include? "type"
end
sti_parent_class() click to toggle source

for creating routes which are based on the parent class

# File lib/dynamic_model_active_record_extensions.rb, line 27
def sti_parent_class
  self.superclass
end