Search code examples
ruby-on-railsactiverecordrollback

Automatic rollback without any error?


I'm unable to create a row in the DB. Rails apparently starts and then immediately rolls back the transaction without any errors. I'm using sqlite3.

  logger.debug("creating billing name...")
  BillingName.create() #also tried BillingName.new.save
  logger.debug("...created")

Log file:

 creating billing name...
 ^[[1m^[[36m (0.1ms)^[[0m  ^[[1mbegin transaction^[[0m
 ^[[1m^[[35m (0.1ms)^[[0m  rollback transaction
 ...created

select * from billing_name shows indeed no entry has been added. How can I tell why the transaction is being rejected?


Solution

  • You can check the errors after a save or valid?

    billing_name = BillingName.new
    billing_name.save # or billing_name.valid?
    puts billing_name.errors.inspect