Closed KSH-code closed 2 years ago
Hi. If you can give a minimal example to reproduce this error, we could take a look.
Oooops, sorry to too late reply.
table info
corners
displays
Our model code is
class Corner
has_many :displays, inverse_of: :corner, foreign_key: :corner_id
def change_status
self.status = 10 # For simple
end
end
class Display
belongs_to :corner, inverse_of: :displays, foreign_key: :corner_id
after_save :update_corner_status
private
def update_corner_status
corner.change_status
corner.save!
end
end
class DisplayForm < ActiveType::Record[Display] # for callbacks via submit form
end
code to raise error
corner = load_corner
display = ActiveType.cast(corner.displays.build, DisplayForm)
display.save!
If lack of code, please mention me!
From 1.8.0, with rails 6.1.4, the duplicate key error occurs when unsaved and casted object is saved.
e.g.
I'm investigating how to reproduce the problem using current repository.
Before complete investigating, to report, I created this issue.
p.s. I'm using MariaDB.