Instance Methods Should Implement Domain Concepts from the DB
Explore how to create instance methods in Rails Active Record models that reflect core domain concepts sourced directly from the database. Understand when to add methods for domain clarity and when to delegate presentational logic to views or helpers to keep models clean and focused.
We'll cover the following...
Modeling derived data in Active Record methods
Outside of business logic, the most common area of trouble has to do with derived data—data whose value is based on the data in the database. We see this when we’re dealing with methods on an Active Record. Sometimes, this derived data is presentational and use case specific, but other times, it represents a true domain concept that is core to the models’ existence. We need to be careful about how we model the data inside the application. This requires a solid understanding of our domain and ...