Trying to create a new record and save it

I think this should work, I have a Transactions model, and I’m trying to create a new record…

     transaction = do |t|
          t.user_id = cart.user_id
          t.postal_carrier = 'Canada Post'
          t.invoice_number = ''
          t.transaction_msg = "shipment pending..."

It’s not saving anything.

oh, i forgot i have some validations it did not pass.

Yep, when validations don’t pass, will return false. (So will record.valid?) One can then inspect the errors using record.errors.

One small piece of advice, I wouldn’t name a model Transaction for the risk of confusion with an Activerecord Transaction. The alternative would be to qualify your business-land Transaction using some kind of prefix or module. (eg. BusinessTransaction, OurCompany::Transaction, or some similar workaround).

Thanks, I’ll rename it.