trestle-active_storage 0.0.1.pre.3 → 0.0.1.pre.4

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: e11a60cc2b7ba1cde176e8c2da26f31649978ab0c3d78d93386655988aa1b3aa
4
- data.tar.gz: c6a5d0e5dce902e940ea0b835b802cd8b990a368d84f0250f013a42900067df0
3
+ metadata.gz: 350fc548afdfb1dc065e0f633fc698210b770f6b867d457d40a324c228b6ea08
4
+ data.tar.gz: 70890ea96e1d62a19325c278c6dfa9396ac6f028119187fa68e70bf24ba27b63
5
5
  SHA512:
6
- metadata.gz: 71d4a575d890ac38e29c3d8cdc5d7472fdf6eaf5852ba546198a03789d864fab460e79e8bf3990e300d51ac184aecdc11009dfe70e25cbc265b11db2b313e3c3
7
- data.tar.gz: 11cd617c1ca1f47c44f4fbfac0c5ebd1545a5b0ff0df28f87f02953eb0fb5612862acc856044c81911b1d4dadfd00ccf659313f6f146162f19a86e95874e62f8
6
+ metadata.gz: 3752d6ec1a0203f7e838cf621d3b24fce9518481a17a5f7884a47c28a9946a3d8e93aa4fa3364e401bb7c7da73f3b9843e99b0e90894b7948d89466f9c3e4ca9
7
+ data.tar.gz: 061f069fabfa556b02d9fc7bcdfce9e606ab54395a01f9f29468246d035dbe550442737c352b85b301bd3bcb871b2710bba72cc91b0ee9dd00678521e5183065
@@ -4,6 +4,7 @@ module Trestle
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
+ before_action :define_attachment_accessors, only: [:edit, :update]
7
8
  before_action :delete_attachment_params, only: [:create, :update]
8
9
  after_action :attach_attachments, only: %i[create update]
9
10
  after_action :purge_attachments, only: %i[update]
@@ -11,6 +12,14 @@ module Trestle
11
12
 
12
13
  protected
13
14
 
15
+ def define_attachment_accessors
16
+ self.instance = admin.find_instance(params)
17
+
18
+ admin.active_storage_fields.each do |field|
19
+ instance.class.send(:attr_accessor, "delete_#{field}")
20
+ end
21
+ end
22
+
14
23
  def delete_attachment_params
15
24
  admin.active_storage_fields.each { |field| params.delete(field) }
16
25
  end
@@ -5,7 +5,6 @@ module Trestle
5
5
  instance = builder.object
6
6
  attachment = instance.send(name)
7
7
 
8
- instance.class.send(:attr_accessor, "delete_#{name}")
9
8
  @template.render partial: 'trestle/active_storage/field',
10
9
  locals: {
11
10
  builder: builder,
@@ -1,5 +1,5 @@
1
1
  module Trestle
2
2
  module ActiveStorage
3
- VERSION = '0.0.1.pre.3'
3
+ VERSION = '0.0.1.pre.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.3
4
+ version: 0.0.1.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails