attribute base_class

Ruby on Rails 8.0.5.1

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.4 v8.0.5.1 v8.1.4 edge

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

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close