trestle-active_storage 0.0.1.pre → 0.0.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13e31341f7353ec3b05de354b4c72a8d438fb4ecce73fadd240a26c58e980f1a
|
4
|
+
data.tar.gz: 8f228fe30a74b0442de98b8f9a8905941af3da727f471ee308efcbd149c5278e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9182615711e63e73f8cf29e4652dce6b1ac1e557613e3b77f8f2db0e3fbdc7fbdef1b69b6efa08f8176f3ab07ef2aac8cdce5348e50857f9429bb6d8debfb62e
|
7
|
+
data.tar.gz: bee83d9db02dbbc1d847b6b1718d83a61633901a22fc67dc98a04e0bb2e12f1c578d431d383ae3f74a6c4b495d77c00abfae3bed6f98bdf7c4738fc4e4717951
|
@@ -5,9 +5,8 @@ module Trestle
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
before_action :delete_attachment_params, only: [:create, :update]
|
8
|
-
|
9
|
-
after_action :
|
10
|
-
after_action :delete_attachments, only: %i[update]
|
8
|
+
after_action :attach_attachments, only: %i[create update]
|
9
|
+
after_action :purge_attachments, only: %i[update]
|
11
10
|
end
|
12
11
|
|
13
12
|
protected
|
@@ -16,15 +15,7 @@ module Trestle
|
|
16
15
|
admin.active_storage_fields.each { |field| params.delete(field) }
|
17
16
|
end
|
18
17
|
|
19
|
-
def
|
20
|
-
self.instance = admin.find_instance(params)
|
21
|
-
|
22
|
-
admin.active_storage_fields.each do |field|
|
23
|
-
instance.class.send(:attr_accessor, "delete_#{field}")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def set_attachments
|
18
|
+
def attach_attachments
|
28
19
|
instance_params = admin.permitted_params(params)
|
29
20
|
|
30
21
|
admin.active_storage_fields.each do |field|
|
@@ -34,7 +25,7 @@ module Trestle
|
|
34
25
|
end
|
35
26
|
end
|
36
27
|
|
37
|
-
def
|
28
|
+
def purge_attachments
|
38
29
|
admin.active_storage_fields.each do |field|
|
39
30
|
instance.send(field).purge if instance.try("delete_#{field}") == '1'
|
40
31
|
end
|