instance method
primary_abstract_class
Ruby on Rails 7.1.6
Since v7.0.10Signature
primary_abstract_class()
Sets the application record class for Active Record
This is useful if your application uses a different class than ApplicationRecord for your primary abstract class. This class will share a database connection with Active Record. It is the class that connects to your primary database.
Source
# File activerecord/lib/active_record/inheritance.rb, line 177
def primary_abstract_class
if ActiveRecord.application_record_class && ActiveRecord.application_record_class.name != name
raise ArgumentError, "The `primary_abstract_class` is already set to #{ActiveRecord.application_record_class.inspect}. There can only be one `primary_abstract_class` in an application."
end
self.abstract_class = true
ActiveRecord.application_record_class = self
end
Defined in activerecord/lib/active_record/inheritance.rb line 177
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Inheritance::ClassMethods