active_shrine 0.7.0 → 0.7.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0330c7363b9c8b14e0f718886933c33dff3998618da11b47e5d14e813def269
4
- data.tar.gz: eda5c702640dd7c6b884ffd6aea3bf9246dffb729100d8d762bb109a6e35e79e
3
+ metadata.gz: 3f065c42ed2f757f8bbd3ed001d303bcd81a1b492f661e9a37226579009a2561
4
+ data.tar.gz: b4ff34b56c8a3deb7daa4f29e83ba38f715072c1544a6c8aeddbc5b81a4694bd
5
5
  SHA512:
6
- metadata.gz: 31e7f98809b76810e2056389ef8512c1f990864d6ec05324bee267b00f9381aace0182fb1a4fb1043d54617d42ab45ccae12199af112df55beeff016115ce307
7
- data.tar.gz: 9010a2da61a53f475fc24b258892a179848dcd93e36fe38f7e3a257d451b0ad43977497d5a63e4f68c95b30f47f63a9f6764324a5780de56c8e40315b416677d
6
+ metadata.gz: 69ea2bf8b0e93d7686d867096726440cce536c764d486ea88663f0054833ea5c985bcb6b1619205f9689bcb132679045779075a5acb1e9f21e0fc6205bf3ab00
7
+ data.tar.gz: e17ac504880cde68f96a2f3b5d0ec66362bd3813c2da9e593050367bd9414900c6f755fdd1ba2541a7b65c61906c6a111cdf8d20955bc0edbae410e18ce09bac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.2] - 2026-08-16
4
+
5
+ - Store the record pointer in attachment metadata under string keys, so it is no longer duplicated as both symbols and strings
6
+
7
+ ## [0.7.1] - 2026-04-16
8
+
9
+ - Bridge attacher errors to `record.errors` on `has_many_attached`
10
+
3
11
  ## [0.7.0] - 2026-04-15
4
12
 
5
13
  - Support `variant:` and `strict:` options in `Attachment#url`
@@ -20,9 +20,16 @@ module ActiveShrine
20
20
  end
21
21
 
22
22
  def save
23
+ raise ActiveRecord::RecordInvalid.new(record) unless valid?
24
+
23
25
  assign_associated_attachments
24
26
  end
25
27
 
28
+ def valid?
29
+ # .map then .all? — don't short-circuit; collect errors from every subchange
30
+ subchanges.map(&:valid?).all?
31
+ end
32
+
26
33
  private
27
34
 
28
35
  def subchanges
@@ -23,15 +23,19 @@ module ActiveShrine
23
23
  end
24
24
 
25
25
  def save
26
- unless attachment.valid?
27
- attachment.errors.each do |error|
28
- record.errors.add(name, error.message)
29
- end
26
+ raise ActiveRecord::RecordInvalid.new(record) unless valid?
30
27
 
31
- raise ActiveRecord::RecordInvalid.new(record)
28
+ record.public_send(:"#{name}_attachment=", attachment)
29
+ end
30
+
31
+ def valid?
32
+ return true if attachment.valid?
33
+
34
+ attachment.errors.each do |error|
35
+ record.errors.add(name, error.message)
32
36
  end
33
37
 
34
- record.public_send(:"#{name}_attachment=", attachment)
38
+ false
35
39
  end
36
40
 
37
41
  private
@@ -116,7 +116,13 @@ module ActiveShrine
116
116
  def maybe_store_record
117
117
  return unless record.present?
118
118
 
119
- metadata.merge! record_type:, record_id:
119
+ # String keys, because metadata comes back from its JSON column with
120
+ # string keys and this runs on every save. Merging symbols in left the
121
+ # pointer under both spellings, which the json gem warns about now and
122
+ # refuses from 3.0. Shrine persists again from its own after_save, so
123
+ # an attachment that receives a file after its row exists saves twice
124
+ # and hits this on the second pass.
125
+ metadata.merge!("record_type" => record_type, "record_id" => record_id)
120
126
  end
121
127
  end
122
128
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveShrine
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shrine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radioactive Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-15 00:00:00.000000000 Z
11
+ date: 2026-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties