administrate_ransack 0.5.0 → 0.6.0
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/README.md +33 -0
- data/lib/administrate_ransack/searchable.rb +2 -1
- data/lib/administrate_ransack/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32afd347fc9d0dda302dca3c72f83a214a22f49394fbf987f45800ab1d549a90
|
4
|
+
data.tar.gz: 7c355e92c9b79610fa9bc8323e0f8231deb22b05ce1204446f5a72a61ff21749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e374f0de682af5cfbdfaf26274768016bfa4446d64e1ca47052a20339d81baa0cc62dc0b08542af0e52c0a0ef1987b080ee015e2ed09ad5d09fecb6815a4671
|
7
|
+
data.tar.gz: b42a18d64406cbf2e91594c5f7f740508cdc0fb3ed641e0216c551f2a7d2b1467154613dfc9be744faa8863e529b61194ccffe9b28794c5cac6acb07878d44b4
|
data/README.md
CHANGED
@@ -27,6 +27,24 @@ prepend AdministrateRansack::Searchable
|
|
27
27
|
<%= render('administrate_ransack/filters') %>
|
28
28
|
```
|
29
29
|
|
30
|
+
- Update your model (ex. Post) exposing the ransackable attributes and associations, skipping this step will raise an exception that explains in details:
|
31
|
+
|
32
|
+
```rb
|
33
|
+
class Post < ApplicationRecord
|
34
|
+
# ...
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def ransackable_attributes(_auth_object = nil)
|
38
|
+
%w[title description]
|
39
|
+
end
|
40
|
+
|
41
|
+
def ransackable_associations(_auth_object = nil)
|
42
|
+
%w[author]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
30
48
|
- See the Usage section for extra options
|
31
49
|
|
32
50
|
## Usage
|
@@ -99,6 +117,21 @@ end
|
|
99
117
|
|
100
118
|
## Customizations
|
101
119
|
|
120
|
+
- Ransack options can be customized defining a `ransack_options` method in the controller, example:
|
121
|
+
|
122
|
+
```rb
|
123
|
+
module Admin
|
124
|
+
class PostsController < Admin::ApplicationController
|
125
|
+
prepend AdministrateRansack::Searchable
|
126
|
+
|
127
|
+
def ransack_options
|
128
|
+
# raises an exception on unknown parameters
|
129
|
+
{ ignore_unknown_conditions: false }
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
102
135
|
- Sample call of the filters partial with different options provided:
|
103
136
|
|
104
137
|
```erb
|
@@ -5,7 +5,8 @@ require 'ransack'
|
|
5
5
|
module AdministrateRansack
|
6
6
|
module Searchable
|
7
7
|
def scoped_resource
|
8
|
-
|
8
|
+
options = respond_to?(:ransack_options) ? ransack_options : {}
|
9
|
+
@ransack_results = super.ransack(params[:q], **options)
|
9
10
|
@ransack_results.result(distinct: true)
|
10
11
|
end
|
11
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate_ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: ransack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.3'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '2.3'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5'
|
41
47
|
description: A plugin for Administrate to use Ransack for search filters
|
42
48
|
email:
|
43
49
|
- mat@blocknot.es
|