administrate-field-active_storage 0.3.2 → 0.3.3
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/.ruby-version +1 -1
- data/README.md +26 -0
- data/administrate-field-active_storage.gemspec +1 -1
- data/app/views/fields/active_storage/_item.html.erb +1 -1
- data/lib/administrate/field/active_storage.rb +1 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a624daf75a65cdb108890eb6ff49339e892cbbf62760e929f3cd5d8b1b2a88cd
|
4
|
+
data.tar.gz: 1c629150cb04295ff58747895ab9b580b33152b349436f74571a8cd9ab5ce79b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62b4b4c33a34448427fc9f5bc4de2ffc0b6df8e8b725d7374df93e3adfbaa5c67e75d20aeb6453e840d8d87a9e92979766f52f22a2ff5ab77173e4c922a056c6
|
7
|
+
data.tar.gz: 2a4eedbe6a85ad22092943bb38864817608e57e630e4b36c2185ed55bccd5503dc4f361838a27858c82eaf33594e97e7205e9939416775c3979950dc86fd3f04
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.5
|
data/README.md
CHANGED
@@ -102,7 +102,33 @@ module Admin
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
```
|
105
|
+
For `has_one_attached` cases, you will use:
|
105
106
|
|
107
|
+
```rb
|
108
|
+
# routes.rb
|
109
|
+
...
|
110
|
+
namespace :admin do
|
111
|
+
...
|
112
|
+
resources :users do
|
113
|
+
delete :avatar, on: :member, action: :destroy_avatar
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# app/controllers/admin/users_controller.rb
|
118
|
+
module Admin
|
119
|
+
class UsersController < ApplicationController
|
120
|
+
|
121
|
+
# For illustrative purposes only.
|
122
|
+
#
|
123
|
+
# **SECURITY NOTICE**: first verify whether current user is authorized to perform the action.
|
124
|
+
def destroy_avatar
|
125
|
+
avatar = requested_resource.avatar
|
126
|
+
avatar.purge
|
127
|
+
redirect_back(fallback_location: requested_resource)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
106
132
|
This route can be customized with `destroy_url`. The option expects a `proc` receiving 3 arguments:
|
107
133
|
the Administrate `namespace`, the `resource`, and the `attachment`. The proc can return anything
|
108
134
|
accepted by `link_to`:
|
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "administrate-field-active_storage"
|
5
|
-
gem.version = "0.3.
|
5
|
+
gem.version = "0.3.3"
|
6
6
|
gem.authors = ["Hamad AlGhanim"]
|
7
7
|
gem.email = ["hamadyalghanim@gmail.com"]
|
8
8
|
gem.homepage = "https://github.com/Dreamersoul/administrate-field-active_storage"
|
@@ -30,7 +30,7 @@ controlled via a boolean local variable.
|
|
30
30
|
<% end %>
|
31
31
|
|
32
32
|
<div>
|
33
|
-
<%= link_to
|
33
|
+
<%= link_to attachment.filename, field.blob_url(attachment), title: attachment.filename %>
|
34
34
|
</div>
|
35
35
|
|
36
36
|
<% if field.destroy_url.present? %>
|
@@ -36,13 +36,7 @@ module Administrate
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def destroy_url
|
39
|
-
options.fetch(:destroy_url)
|
40
|
-
proc do |namespace, record, attachment|
|
41
|
-
options = [attachment.name, namespace, record]
|
42
|
-
options << { attachment_id: attachment.id } if many?
|
43
|
-
options
|
44
|
-
end
|
45
|
-
end
|
39
|
+
options.fetch(:destroy_url, nil)
|
46
40
|
end
|
47
41
|
|
48
42
|
# currently we are using Rails.application.routes.url_helpers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate-field-active_storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamad AlGhanim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|