SOLID Principles in Ruby on Rails SOLID is not a Rails or Ruby concept. It's a set of five object-oriented design principles that apply to any language/framework. But Rails makes it surprisingly easy to violate all five of them. Let's start with Single Responsibility Principle It states a class should have only one reason to change. A classic example is a User model that handles authentication, sends emails, and formats reports. That's three responsibilities. Instead, you'd extract email sending into a Mailer class and reporting into a service object. class User def authenticate end def send_welcome_email end def generate_report end end Enter fullscreen mode Exit fullscreen mode The Fix class User < ApplicationRecord has_many :orders validates :email , presence: true end class UserAuthenticationService def authenticate end end class UserMailer < ApplicationMailer def send_welcome_email ( user ) end end class UserReportService def generate_report end end Enter fullscreen mode Exit fullscreen mode In…