# ActiveRecord Topics: [[Ruby on Rails]] The [[Active Record pattern]] wasn't invented for [[Ruby on Rails]]. It was named by [[Martin Fowler]] in [[Patterns of Enterprise Software Architecture (book)]]. The basic idea behind this pattern is that every table in a database has a corresponding class in the application code. Each instance of the class represents one row of data in the related table. ## Bloated models Model classes based on ActiveRecord tend to attract code. This is often the consequence of the common "Skinny controllers, fat models" mantra. The goal of keeping [[ActiveController|Rails controllers]] lean leads developers to shove all business logic into models. However, this doesn't solve the bloating issue, it just moves it from controllers to models. There are, however, ways to solve the issue properly. One is to add new, separate objects that implement specific pieces of business logic which aren't the main responsibility of a model (see [[Single Responsibility Principle]]. Another tactic is to use [[Rails concerns]] to push logic that is tangential but tightly coupled to a model to the periphery. That way, a model class stays more readable. Jason Swett discusses these tactics in detail in [What to do about bloated Rails Active Record models](https://www.codewithjason.com/bloated-rails-active-record-models/). ## Default values - [Assign a default value to an attribute in Active Record - Andy Croll](https://andycroll.com/ruby/assign-a-default-to-an-attribute-active-record/) ## Related - [[Database]]