Method: ActiveRecord::Inheritance::ClassMethods#base_class

Defined in:
activerecord/lib/active_record/inheritance.rb

#base_classObject (readonly)

Returns the first class in the inheritance hierarchy that descends from either an abstract class or from ActiveRecord::Base.

Consider the following behaviour:

class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end
class Shape < ApplicationRecord
  self.abstract_class = true
end
Polygon = Class.new(Shape)
Square = Class.new(Polygon)

ApplicationRecord.base_class # => ApplicationRecord
Shape.base_class # => Shape
Polygon.base_class # => Polygon
Square.base_class # => Polygon


115
116
117
# File 'activerecord/lib/active_record/inheritance.rb', line 115

def base_class
  @base_class
end