💎 Ruby on Rails
Beginner
What is ActiveRecord::Base vs ApplicationRecord?
Answer
In older Rails, models directly inherited from ActiveRecord::Base. Rails 5 introduced ApplicationRecord, a custom base class that inherits from ActiveRecord::Base, and all models now inherit from ApplicationRecord instead. This provides a single place to add shared model behavior (shared scopes, class methods, included modules) for all models in the app — similar to how ApplicationController works. It follows the Single Table Inheritance principle and makes it easy to patch or extend ActiveRecord behavior app-wide.
Previous
What is the difference between belongs_to and has_one?
Next
What is eager loading vs lazy loading in Rails?