Rails

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:,...

[ruby] your_model = User column_names = your_model.column_names - ['created_at', 'updated_at'] # we can ignore some unimportant fields backup_array = [] your_model.find_each(batch_size: 500) do |your_record| p_hash = {} column_names.each do |col_name| p_hash.merge!("#{col_name}" => your_record.send(col_name)) end backup_array << p_hash end [/ruby] This will create an array of...