0

I upgraded my Rails 5.1.6 app on Ruby 2.4 to Rails 5.2 on Ruby 2.5.1 by making a new rails 5.2 app then transferring all the app files to it.

I noticed the following changes:

  • coffee script stopped working (no problem, I just changed to js)
  • creating new records stopped working, but editing existing records was ok. I just get the rollback error below:

    2.5.1 :005 > Item.create(name: "asdf") (0.3ms) BEGIN (0.8ms) ROLLBACK ..

Is there anything in Rails 5.2 that affects new records in Active Record?

Jun Dalisay
  • 1,165
  • 2
  • 12
  • 26
  • I'm seeing the same problem after updating from `5.1.6` to `5.2.2` - did you figure out the problem? It has nothing to do with `optional: true` as far as I can see.. – xijo Jan 04 '19 at 13:18
  • I didn't upgrade to 5.2.2 because this previous change already gave me headache. I would rather start from scratch as a new 5.2.2 app on the latest Ruby – Jun Dalisay Jan 07 '19 at 07:12

1 Answers1

1

It turns out that optional: true has to be set for every belongs_to in Rails 5:

belongs_to :another_record, optional: true
Jun Dalisay
  • 1,165
  • 2
  • 12
  • 26