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: a5b3855fce2dd9e8a24d802e0cc24a5c5dbf6e3e03f264f9bf1b0f9f81a747d0
4
- data.tar.gz: ab35d5f69c6bdee1173791cd2e830a5eb18eb9db60fa1f57f9c033244230c6bb
3
+ metadata.gz: 13e31341f7353ec3b05de354b4c72a8d438fb4ecce73fadd240a26c58e980f1a
4
+ data.tar.gz: 8f228fe30a74b0442de98b8f9a8905941af3da727f471ee308efcbd149c5278e
5
5
  SHA512:
6
- metadata.gz: 26b0b26dbb1d88b8e2282a62d7f36c3f768cd3b87e69fedc3a7d33621c5098a4f1898adefd6a0b6f457a8bf9d76759156fc9c31210c8db27552f9666997bd885
7
- data.tar.gz: fcfca0545c41d0ae9c7d3627f4deb20e1bc47e887b1c9ae93d5ef3d6b29c3d03a2fb0a1ea3762a989ab7f4bba406e65d6ed5a4bffe3e766ef52508c8893facee
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
- before_action :define_attachment_accessors, only: [:edit, :update]
9
- after_action :set_attachments, only: %i[create update]
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 define_attachment_accessors
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 delete_attachments
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
@@ -5,6 +5,7 @@ module Trestle
5
5
  instance = builder.object
6
6
  attachment = instance.send(name)
7
7
 
8
+ instance.class.send(:attr_accessor, "delete_#{name}")
8
9
  @template.render partial: 'trestle/active_storage/field',
9
10
  locals: {
10
11
  builder: builder,
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module ActiveStorage
3
- VERSION = '0.0.1.pre'
3
+ VERSION = '0.0.1.pre.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trestle-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre
4
+ version: 0.0.1.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman