What is a service object in Rails?

Answer

A service object is a Plain Old Ruby Object (PORO) that encapsulates a single business operation or use case, keeping controllers thin and models focused on data concerns. Example: UserRegistrationService.new(params).call handles validation, record creation, email sending, and logging — all in one place. Typically stored in app/services/. Common conventions: a single public call method, a class-level .call shorthand, and returning a result object. Service objects improve testability, readability, and separation of concerns when business logic grows complex.