27 Apr Rails: How to respond with custom error messages in the ActiveRecord way without having a model
Here you have a quick example: Let's begin with the service for that. app/services/format_response_with_active_model_errors.rb [ruby] class FormatResponseWithActiveModelErrors extend ActiveModel::Naming def initialize @errors = ActiveModel::Errors.new(self) end def valid? errors.empty? end attr_reader :errors attr_accessor :response def add_error_message!(field_name:,...