inline_forms 8.1.15 → 8.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/app/controllers/inline_forms_controller.rb +35 -9
- data/lib/inline_forms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a523b9082f8bf1ada004984c1d3cc66e745cae0e525e36acbf66df97b7015e98
|
|
4
|
+
data.tar.gz: d82f9950bde7f293ea70ef2e63162bcb304a0fac44eb6c8f645f88bbefe947da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 275bec7794f426e5131ae69843dfcb9bd2cec55ae9124075bc59ae0e171fc6df3d406ae776d78526a918a12dbc87aa41b0b12ade138fd4f520d75254570e6b01
|
|
7
|
+
data.tar.gz: 33bb93de6e2f017d664b610e07105afea73708b5ee67a269b48bd68de6b3d0fa8b9688eab4c21882ea408a8fc7ab68fcf6e2a18ff733d56fad29110e5863790e
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [8.1.16] - 2026-05-28
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **`RecordNotUnique` on `action_text_rich_texts.id` when undoing a delete more than once.** Restoring rich text after parent undo used `reify.save!`, which INSERTs the old primary key. A second delete/undo cycle (or an already-restored row) hit SQLite's unique constraint. Restoration now upserts by `(record_type, record_id, name)` and copies `body` only, and only the latest PaperTrail `destroy` version per attribute is applied.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **Regression test:** nested Photo delete → undo → delete → undo.
|
|
16
|
+
|
|
7
17
|
## [8.1.15] - 2026-05-28
|
|
8
18
|
|
|
9
19
|
### Fixed
|
|
@@ -331,23 +331,49 @@ class InlineFormsController < ApplicationController
|
|
|
331
331
|
# Undoing a parent +destroy+ reifies the Apartment/Photo row only. ActionText
|
|
332
332
|
# bodies live in +action_text_rich_texts+ and get their own PaperTrail
|
|
333
333
|
# +destroy+ versions; those rows are gone after +parent.destroy+, so we also
|
|
334
|
-
# reify
|
|
334
|
+
# reify each matching +ActionText::RichText+ destroy snapshot.
|
|
335
|
+
#
|
|
336
|
+
# Use +find_or_initialize_by(record_type, record_id, name)+ and copy +body+
|
|
337
|
+
# only. Reified rows carry the old PK; +save!+ on a new record would INSERT
|
|
338
|
+
# that id and raise +RecordNotUnique+ on a second delete/undo cycle when the
|
|
339
|
+
# row already exists. Only the newest destroy version per attribute name is
|
|
340
|
+
# applied (repeat delete/undo leaves multiple RT destroy versions in the table).
|
|
335
341
|
def restore_rich_texts_for_reverted_parent!(parent)
|
|
336
342
|
return unless defined?(ActionText::RichText)
|
|
337
343
|
|
|
338
344
|
record_type = parent.class.base_class.name
|
|
339
345
|
record_id = parent.id
|
|
346
|
+
versions_by_name = {}
|
|
347
|
+
|
|
348
|
+
PaperTrail::Version
|
|
349
|
+
.where(item_type: "ActionText::RichText", event: "destroy")
|
|
350
|
+
.order(id: :desc)
|
|
351
|
+
.each do |version|
|
|
352
|
+
attrs = version.object_deserialized
|
|
353
|
+
next unless attrs.is_a?(Hash)
|
|
340
354
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
355
|
+
type = attrs["record_type"] || attrs[:record_type]
|
|
356
|
+
rid = attrs["record_id"] || attrs[:record_id]
|
|
357
|
+
next unless type == record_type && rid.to_i == record_id
|
|
344
358
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
name = (attrs["name"] || attrs[:name]).to_s
|
|
360
|
+
next if name.empty?
|
|
361
|
+
|
|
362
|
+
versions_by_name[name] ||= version
|
|
363
|
+
end
|
|
348
364
|
|
|
349
|
-
|
|
350
|
-
|
|
365
|
+
versions_by_name.each_value do |version|
|
|
366
|
+
reified = version.reify
|
|
367
|
+
next unless reified
|
|
368
|
+
|
|
369
|
+
name = reified.name.to_s
|
|
370
|
+
record = ActionText::RichText.find_or_initialize_by(
|
|
371
|
+
record_type: record_type,
|
|
372
|
+
record_id: record_id,
|
|
373
|
+
name: name
|
|
374
|
+
)
|
|
375
|
+
record.body = reified.body if reified.respond_to?(:body)
|
|
376
|
+
record.save!
|
|
351
377
|
end
|
|
352
378
|
end
|
|
353
379
|
|
data/lib/inline_forms/version.rb
CHANGED