Ruby 3 - Save without validation no longer works on one table

Viewed 115

I am upgrading an application from Ruby 2.6.10 to Ruby 3.0.4 and have a very odd situation. When I execute the command record.save(validate: false) on one of my tables I am getting the error message:

ArgumentError: wrong number of arguments (given 1, expected 0)
from /tmp/bundle/ruby/3.0.0/gems/activerecord-6.1.6/lib/active_record/suppressor.rb:43:in `save'

The error occurs even when I perform the operation:

record = ModelName.last
record.save(validate: false)

I can perform the same operation on other tables and it works fine. I have disabled all validations and callbacks in the model, to no avail.

The same operation worked fine on this table (and all others) in Ruby 2.6.10.

I see nothing particular on the (anonymized) model:

  create_table "my_table", id: :integer, charset: "utf8mb4", collation: "utf8mb4_german2_ci", force: :cascade do |t|
    t.integer "field_1"
    t.string "field_2"
    t.integer "field_3"
    t.string "field_4"
    t.string "field_5"
    t.string "field_6"
    t.string "field_7"
    t.text "field_8", size: :long
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.text "field_9", size: :long
    t.string "state", default: "raw", null: false
    t.text "field_10", size: :long
    t.datetime "field_11"
    t.index ["state"], name: "...text replaced..."

I have exactly the same problem on Ruby 3.1.2 as well.

Does anyone have suggestions on how I can debug this? Is there something trivial I might be overlooking?

2 Answers

Had the same problem with ruby 3.0.4 and cause was state_machine gem.

state_machine/integrations/active_record.rb:487: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call

Saw only warning, when switched back to ruby 2.7.6 and rerun test. Test passed, but warning was there.

Resolved, by fixing fork of gem repo. If anyone encounters the same, feel free to add it in Gemfile:

gem 'state_machine', git: 'https://github.com/Faq/state_machine.git', ref: 'd55bb212a62299837833f7b6d5f14e42bc0df8d8'

Root cause was a gem that was used in a before_save hook.

Related