administrate-field-active_storage 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: '09680d84898084c57e5074d113530d27fb7d7ae1'
4
- data.tar.gz: 4da191e3ba06952160837bb122ad242e1cfc8ef9
3
+ metadata.gz: 5285346aa1dc6b65131ea17ef5a8a4da7e98ac8d
4
+ data.tar.gz: 9c9c2adcdd61a37a98619468d758d51ac68acd33
5
5
  SHA512:
6
- metadata.gz: 1ab9acf4c492cf3c344fb96cd66d6eb800616269226761ccb1e1fc4981f9340b1615c8cb8fb5ee82bca8d1ce3b141937e35f3ea5a7669acd899045be426cc900
7
- data.tar.gz: 43e86708e5ed5baba482887db772f51d30b6faee422d88d6ffea5e7648d25d37e0aa46594682eab9522dc6aa5d7817347e50fe7fa57bba86c53aa3e008f984f4
6
+ metadata.gz: 9876395df4d430f9342242e6d323a6be28d09ec136fab6f7261d752b551d71418dec39cbbfdc1a7fbf93f4b5db50728a01425ad217d4fb3a0c28c57b31d9810a
7
+ data.tar.gz: e3be245465e3974fea1c9f8e92ff9cbb0f67c907af424cb56e38dfbf579ebce97d409dc3f1c73cb88f8c47563efcf4375408c9fb290bc17f8d9a6bdaf2a5b4ef
data/README.md CHANGED
@@ -52,6 +52,22 @@ class ModelDashboard < Administrate::BaseDashboard
52
52
  ```
53
53
  I know it is not ideal, if you have a workaround please submit a PR.
54
54
 
55
+ ### Prevent N+1 queries
56
+ In order to prevent N+1 queries from active storage you have to modify your admin model controller, below an example for a model called `User` and with attached avatars
57
+ ```ruby
58
+ module Admin
59
+ class UsersController < Admin::ApplicationController
60
+ def index
61
+ super
62
+ @resources = User.with_attached_avatars.
63
+ page(params[:page]).
64
+ per(10)
65
+ end
66
+ end
67
+ end
68
+
69
+ ```
70
+
55
71
  ### Removing/Deleting an Attachment
56
72
  In order to allow the user to delete an attachment using the admin dashboard you need to do the following:
57
73
  1. create a controller action with a `delete` route
@@ -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.1.7"
5
+ gem.version = "0.1.8"
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"
data/contribute.md CHANGED
@@ -4,4 +4,5 @@
4
4
  - Mario Zigliotto [@mariozig](https://github.com/mariozig)
5
5
  - Leif Gensert [@leifg](https://github.com/leifg)
6
6
  - Kadu Diógenes [@cerdiogenes](https://github.com/cerdiogenes)
7
- - Peter Bhat Harkins [@pushcx](https://github.com/pushcx)
7
+ - Peter Bhat Harkins [@pushcx](https://github.com/pushcx)
8
+ - Delta Purna Widyangga [@deltapurna](https://github.com/deltapurna)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- administrate-field-active_storage (0.1.6)
4
+ administrate-field-active_storage (0.1.7)
5
5
  administrate (>= 0.2.0.rc1)
6
6
  rails (>= 5.2)
7
7
 
@@ -3,12 +3,12 @@ module Admin
3
3
  # To customize the behavior of this controller,
4
4
  # you can overwrite any of the RESTful actions. For example:
5
5
  #
6
- # def index
7
- # super
8
- # @resources = User.
9
- # page(params[:page]).
10
- # per(10)
11
- # end
6
+ def index
7
+ super
8
+ @resources = User.with_attached_avatars.
9
+ page(params[:page]).
10
+ per(10)
11
+ end
12
12
 
13
13
  # Define a custom finder by overriding the `find_resource` method:
14
14
  # def find_resource(param)
@@ -16,7 +16,7 @@ module Administrate
16
16
  end
17
17
 
18
18
  def show_in_index?
19
- options.key?(:destroy_path)
19
+ options.fetch(:show_in_index, false)
20
20
  end
21
21
 
22
22
  def show_preview_size
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.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamad AlGhanim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-05 00:00:00.000000000 Z
11
+ date: 2019-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate