def batch_update
      params[:batch]&.to_unsafe_h&.each do |batch_resource, objects|
        objects = Array.wrap(objects).select { |object| object['id'].present? }
        batch_resource = batch_resource.to_s
        batch_module = batch_resource.underscore.singularize.to_sym
        resource = batch_resource.classify.constantize
        authorize_for(action: :update,
                      resource: batch_module)
        objects.each do |batch_object|
          authorize_for(action: :update,
                        resource: batch_module,
                        object: resource.new(batch_object))
        end
        resource.update(objects.map { |obj| obj['id']}, objects)
      end
      head :accepted if params[:batch].present?
    end
def batch_update
      params[:batch]&.to_unsafe_h&.each do |batch_resource, objects|
        objects = Array.wrap(objects).select { |object| object['id'].present? }
        batch_resource = batch_resource.to_s
        batch_module = batch_resource.underscore.singularize.to_sym
        resource = batch_resource.classify.constantize
        authorize_for(action: :update,
                      resource: batch_module)
        objects.each do |batch_object|
          authorize_for(action: :update,
                        resource: batch_module,
                        object: resource.new(batch_object))
        end
        resource.update(objects.map { |obj| obj['id']}, objects)
      end
      head :accepted if params[:batch].present?
    end
PATCH/PUT /batch_update
 This action updates records based on request payload. It reads the JSON
 taking it's keys as model scope and array values as records to update
 through it's ids.