How do I create an array to represent an empty record?

do you mean like this (for a pointless example)?:

  payment = Payment.new

  payment.total = params[:total]   payment.tax = payment.total * 0.9

  if payment.save     # Data is now save to database table   end

The point being that the table is only modified when you call the save method when creating a new activeRecord object.

The table is not touched until you call save (and then only if the object validates)..

So you generate a transaction number before receiving all the information from the user? Is this necessary? Could you give them the transaction number after it has been accepted?

This is one of the classical breaking points of object-relational mapping - the transaction boundary. It occurs in single user and mutli-user paradigms equally.

If, for auditing purposes, there is a requirement that transaction numbers be sequential, _and_ you don't need a transaction number until the transaction is comitted, then generate your transaction ID at save time within the boundaries of the database transaction.

If, for auditing purposes, there is a requirement that transaction numbers be sequential, _and_ you need transaction numbers early, then make sure that you record thetransactionearly, and be prepared to record the transaction as being canceled by user or aborted due to technical failure.

If there is no need for keeping the transaction number sequential (not likely), then youcan throw away unused numbers. Numbers are cheap, if they have enough digits.