Ruby method that is validating the payload received What is a cleaner and/or clearer way of writing the following method

def disbursements
  @invoice = Invoice.find(params[:id])
  utc_time = Time.parse.now.utc

#check if invoice_id is not nil
  if @invoice.invoice_id == nil
    @invoice.errors[:invoice_id] &lt;&lt; "invoice_id can not be blank"
  end
#check if trip date is now or past
  if utc_time &lt;= @invoice.trips.first
    @invoice.errors[:trips] &lt;&lt; "Funds can not be disbursed yet."
  end
#check if trip had been cancelled
  if @invoice.cancelled == true
    @invoice.errors[:cancelled] &lt;&lt; "This invoice was already been cancelled."
  end
#check if this invoie has been processed before
  if @invoice.service_rendered == true
    @invoice.errors[:service_rendered] &lt;&lt; "This invoice has already been disbursed."
  end
#check all is well
  if @invoice.errors.empty? == false
    render json: @invoice.errors, status: :unprocessable_entity
    return
  end


...
Inline conditionals would make this a bit cleaner:

def disbursements
  @invoice = Invoice.find(params[:id])

  @invoice.errors[:invoice_id] &lt;&lt; 'invoice_id can not be blank' if @invoice.invoice_id.nil?
  @invoice.errors[:trips] &lt;&lt; 'Funds can not be disbursed yet.' if Time.now.utc &lt;= @invoice.trips.first
  @invoice.errors[:cancelled] &lt;&lt; 'This invoice was already been cancelled.' if @invoice.cancelled
  @invoice.errors[:service_rendered] &lt;&lt; 'This invoice has already been disbursed.' if @invoice.service_rendered

  return render json: @invoice.errors, status: :unprocessable_entity if @invoice.errors.any?
  ...
end


We can slim the method down and save a lot of space that way.

I removed the utc_time variable because it was only used once.