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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e2ce06e06ce00cd336d5aad861c93657137a0c059a45bb3d1110c2a8c441ba6
4
- data.tar.gz: eb5dae4623fb4c1c1270e785b423f2a82f619fe6d22bdd4a799be309d90b21dc
3
+ metadata.gz: 32afd347fc9d0dda302dca3c72f83a214a22f49394fbf987f45800ab1d549a90
4
+ data.tar.gz: 7c355e92c9b79610fa9bc8323e0f8231deb22b05ce1204446f5a72a61ff21749
5
5
  SHA512:
6
- metadata.gz: 990b321779498d5f4a73cdf2846a16777767d4b860d69f913785528be4746f2dc50b5e77fcf4cbb8eaf8f439809d7e09678f9e8b14ebb4a7b55b7dae18f848d9
7
- data.tar.gz: c2683c29c7b9d7bb02c71ec5c7349cd104431af0c0b7c31b8e90e8eb88772d107cd0390c709ce171c1d99d3ceeb1843f65566ac4c2d4f8896915783b96756b01
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
- @ransack_results = super.ransack(params[:q])
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdministrateRansack
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
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.5.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: 2023-09-10 00:00:00.000000000 Z
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