'Ruby 3 - Save without validation no longer works on one table
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?
Solution 1:[1]
Root cause was a gem that was used in a before_save hook.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Edward Caulfield |