What is the difference between class methods and instance methods in ActiveRecord?

Answer

In ActiveRecord, class methods are called on the model class itself and typically return a relation or perform bulk operations: User.active (scope), User.count, User.create(...). They are defined with def self.method_name or inside class << self. Instance methods are called on a specific record object: user.full_name, user.save, user.destroy. Knowing this distinction matters for scopes (always class methods returning relations), callbacks (instance methods called on the object), and association methods. A common mistake is accidentally calling a class method on an instance or vice versa, which raises a NoMethodError.