ransack 3.0.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/deploy.yml +35 -0
- data/.github/workflows/test-deploy.yml +29 -0
- data/.github/workflows/test.yml +16 -31
- data/CHANGELOG.md +67 -0
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +2 -2
- data/README.md +5 -5
- data/docs/.gitignore +0 -1
- data/docs/docs/getting-started/simple-mode.md +24 -24
- data/docs/docs/getting-started/sorting.md +1 -1
- data/docs/docs/getting-started/using-predicates.md +1 -1
- data/docs/docs/going-further/acts-as-taggable-on.md +114 -0
- data/docs/docs/going-further/documentation.md +14 -2
- data/docs/docs/going-further/exporting-to-csv.md +2 -2
- data/docs/docs/going-further/merging-searches.md +1 -1
- data/docs/docs/going-further/polymorphic-search.md +40 -0
- data/docs/docs/going-further/wiki-contributors.md +82 -0
- data/docs/docs/intro.md +2 -2
- data/docs/docusaurus.config.js +16 -4
- data/docs/package.json +3 -2
- data/docs/yarn.lock +1311 -546
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -1
- data/lib/polyamorous/activerecord_7.1_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_7.1_ruby_2/join_dependency.rb +1 -0
- data/lib/polyamorous/activerecord_7.1_ruby_2/reflection.rb +1 -0
- data/lib/ransack/adapters/active_record/context.rb +17 -49
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +2 -10
- data/lib/ransack/constants.rb +0 -3
- data/lib/ransack/helpers/form_helper.rb +1 -1
- data/lib/ransack/nodes/value.rb +1 -1
- data/lib/ransack/version.rb +1 -1
- data/ransack.gemspec +3 -3
- data/spec/helpers/polyamorous_helper.rb +2 -8
- data/spec/ransack/helpers/form_helper_spec.rb +24 -0
- data/spec/ransack/nodes/value_spec.rb +115 -0
- metadata +18 -12
- data/docs/package-lock.json +0 -9207
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -20
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -79
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -11
@@ -7,12 +7,24 @@ Ransack uses [Docusaurus](https://docusaurus.io/) for documentation. To contribu
|
|
7
7
|
|
8
8
|
### Local Development
|
9
9
|
|
10
|
+
Switch to docs folder
|
11
|
+
|
10
12
|
```
|
11
13
|
cd docs
|
12
|
-
yarn start
|
13
14
|
```
|
14
15
|
|
15
|
-
|
16
|
+
Install docusaurus and other dependencies
|
17
|
+
|
18
|
+
```
|
19
|
+
yarn install
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
|
+
Start a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
|
24
|
+
|
25
|
+
```
|
26
|
+
yarn start
|
27
|
+
```
|
16
28
|
|
17
29
|
### Build
|
18
30
|
|
@@ -7,7 +7,7 @@ Exporting to CSV
|
|
7
7
|
|
8
8
|
Example downloading a csv file preserving ransack search, based on [this gist](https://gist.github.com/pama/adff25ed1f4b796ce088ea362a08e1c5)
|
9
9
|
|
10
|
-
```
|
10
|
+
```ruby title='index.html.erb'
|
11
11
|
<h1>Users</h1>
|
12
12
|
|
13
13
|
<%= search_form_for @q, url: dashboard_index_path do |f| %>
|
@@ -30,7 +30,7 @@ Example downloading a csv file preserving ransack search, based on [this gist](h
|
|
30
30
|
<% end %>
|
31
31
|
```
|
32
32
|
|
33
|
-
```
|
33
|
+
```ruby title='user.rb'
|
34
34
|
require 'csv'
|
35
35
|
|
36
36
|
class User < ApplicationRecord
|
@@ -38,4 +38,4 @@ WHERE (
|
|
38
38
|
ORDER BY "people"."id" DESC
|
39
39
|
```
|
40
40
|
|
41
|
-
Admittedly this is not as simple as it should be, but it's workable for now. (Implementing
|
41
|
+
Admittedly this is not as simple as it should be, but it's workable for now. (Implementing [issue 417](https://github.com/activerecord-hackery/ransack/issues/417) could make this more straightforward.)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
title: Polymorphic Searches
|
3
|
+
sidebar_position: 14
|
4
|
+
---
|
5
|
+
|
6
|
+
When making searches from polymorphic models it is necessary to specify the type of model you are searching.
|
7
|
+
|
8
|
+
For example:
|
9
|
+
|
10
|
+
Given two models
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
class House < ActiveRecord::Base
|
14
|
+
has_one :location, as: :locatable
|
15
|
+
end
|
16
|
+
|
17
|
+
class Location < ActiveRecord::Base
|
18
|
+
belongs_to :locatable, polymorphic: true
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
Normally (without polymorphic relationship) you would be able to search as per below:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Location.ransack(locatable_number_eq: 100).result
|
26
|
+
```
|
27
|
+
|
28
|
+
However when this is searched you will get the following error
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
ActiveRecord::EagerLoadPolymorphicError: Can not eagerly load the polymorphic association :locatable
|
32
|
+
```
|
33
|
+
|
34
|
+
In order to search for locations by house number when the relationship is polymorphic you have to specify the type of records you will be searching and construct your search as below:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Location.ransack(locatable_of_House_type_number_eq: 100).result
|
38
|
+
```
|
39
|
+
|
40
|
+
note the `_of_House_type_` added to the search key. This allows Ransack to correctly specify the table names in SQL join queries.
|
@@ -0,0 +1,82 @@
|
|
1
|
+
---
|
2
|
+
title: Wiki Contributors
|
3
|
+
sidebar_position: 20
|
4
|
+
---
|
5
|
+
|
6
|
+
Ransack previously had documentation contained in a GitHub Wiki, and this content has been merged into this documentation website. The following long list of _amazing_ people all made contributions to the Wiki:
|
7
|
+
|
8
|
+
* Abinoam P. Marques Jr
|
9
|
+
* Alex Stophel
|
10
|
+
* Andrea Schiavini
|
11
|
+
* Andrew Vit
|
12
|
+
* Ben Koshy
|
13
|
+
* Brainkurv
|
14
|
+
* Brandan Lennox
|
15
|
+
* Brendon Muir
|
16
|
+
* Chris Salzberg
|
17
|
+
* Colleen McGuckin
|
18
|
+
* David Aldridge
|
19
|
+
* Davidson Mohanty
|
20
|
+
* Denis Tataurov
|
21
|
+
* Drew Moore
|
22
|
+
* Eike Send
|
23
|
+
* Feodor Cherashev
|
24
|
+
* Glauco Custódio
|
25
|
+
* Grey Baker
|
26
|
+
* Harold.Luo
|
27
|
+
* Herman Singh
|
28
|
+
* Ian Smith
|
29
|
+
* Jake Haber
|
30
|
+
* Jan Klimo
|
31
|
+
* Jared Beck
|
32
|
+
* Jon Atack
|
33
|
+
* Juanito Fatas
|
34
|
+
* JungaJk
|
35
|
+
* Leo Chen
|
36
|
+
* Leon Miller-Out
|
37
|
+
* Luca F
|
38
|
+
* Marc Poris
|
39
|
+
* Matt Oakley
|
40
|
+
* Michael Kopchick
|
41
|
+
* Nathan Colgate
|
42
|
+
* Nguyen Phi Viet(Sun*)
|
43
|
+
* Nguyễn Đức Long
|
44
|
+
* NielsKSchjoedt
|
45
|
+
* Patrick Copeland
|
46
|
+
* Pedro Chambino
|
47
|
+
* Rene Hopf
|
48
|
+
* Richa Arora
|
49
|
+
* Rob Jones
|
50
|
+
* Roman Sokhan
|
51
|
+
* Ryan Bates
|
52
|
+
* Ryan Bigg
|
53
|
+
* Sean
|
54
|
+
* Sean Linsley
|
55
|
+
* Sergey
|
56
|
+
* Sunny Ripert
|
57
|
+
* Tanbir Hasan
|
58
|
+
* ThuyNguyen97
|
59
|
+
* Vanda
|
60
|
+
* Yana Agun Siswanto
|
61
|
+
* bonyiii
|
62
|
+
* charly
|
63
|
+
* chifung7
|
64
|
+
* colorfulberry
|
65
|
+
* ddonahue99
|
66
|
+
* ernie
|
67
|
+
* gaaady
|
68
|
+
* gingerlime
|
69
|
+
* grumpit
|
70
|
+
* itsalongstory
|
71
|
+
* jonatack
|
72
|
+
* kogre
|
73
|
+
* nguyentrungson97
|
74
|
+
* nslocum
|
75
|
+
* omitter
|
76
|
+
* radar
|
77
|
+
* rilian
|
78
|
+
* terraplane
|
79
|
+
* tyronewilson
|
80
|
+
* vansy61
|
81
|
+
* willnet
|
82
|
+
* wzcolon
|
data/docs/docs/intro.md
CHANGED
@@ -17,7 +17,7 @@ Ransack is supported for Rails 7.0, 6.x on Ruby 2.6.6 and later.
|
|
17
17
|
|
18
18
|
To install `ransack` and add it to your Gemfile, run
|
19
19
|
|
20
|
-
```
|
20
|
+
```ruby title='Gemfile'
|
21
21
|
gem 'ransack'
|
22
22
|
```
|
23
23
|
|
@@ -25,7 +25,7 @@ gem 'ransack'
|
|
25
25
|
|
26
26
|
If you would like to use the latest updates not yet published to RubyGems, use the `main` branch:
|
27
27
|
|
28
|
-
```
|
28
|
+
```ruby title='Gemfile'
|
29
29
|
gem 'ransack', :github => 'activerecord-hackery/ransack', :branch => 'main'
|
30
30
|
```
|
31
31
|
|
data/docs/docusaurus.config.js
CHANGED
@@ -15,7 +15,7 @@ const config = {
|
|
15
15
|
favicon: 'img/favicon.ico',
|
16
16
|
organizationName: 'activerecord-hackery',
|
17
17
|
projectName: 'ransack',
|
18
|
-
trailingSlash:
|
18
|
+
trailingSlash: true,
|
19
19
|
|
20
20
|
presets: [
|
21
21
|
[
|
@@ -25,12 +25,11 @@ const config = {
|
|
25
25
|
docs: {
|
26
26
|
routeBasePath: '/',
|
27
27
|
sidebarPath: require.resolve('./sidebars.js'),
|
28
|
-
editUrl: 'https://github.com/activerecord-hackery/ransack/
|
28
|
+
editUrl: 'https://github.com/activerecord-hackery/ransack/edit/main/docs/',
|
29
29
|
},
|
30
30
|
blog: {
|
31
31
|
showReadingTime: true,
|
32
|
-
editUrl:
|
33
|
-
'https://github.com/activerecord-hackery/ransack/docs/blog/',
|
32
|
+
editUrl: 'https://github.com/activerecord-hackery/ransack/edit/main/blog/',
|
34
33
|
},
|
35
34
|
theme: {
|
36
35
|
customCss: require.resolve('./src/css/custom.css'),
|
@@ -101,8 +100,21 @@ const config = {
|
|
101
100
|
prism: {
|
102
101
|
theme: lightCodeTheme,
|
103
102
|
darkTheme: darkCodeTheme,
|
103
|
+
additionalLanguages: ['ruby', 'erb'],
|
104
104
|
},
|
105
105
|
}),
|
106
|
+
|
107
|
+
themes: [
|
108
|
+
[
|
109
|
+
require.resolve("@easyops-cn/docusaurus-search-local"),
|
110
|
+
{
|
111
|
+
// `hashed` is recommended as long-term-cache of index file is possible.
|
112
|
+
hashed: true,
|
113
|
+
// needs to be the same as routeBasePath in @docusaurus/preset-classic config
|
114
|
+
docsRouteBasePath: '/'
|
115
|
+
},
|
116
|
+
]
|
117
|
+
]
|
106
118
|
};
|
107
119
|
|
108
120
|
module.exports = config;
|
data/docs/package.json
CHANGED
@@ -14,8 +14,9 @@
|
|
14
14
|
"write-heading-ids": "docusaurus write-heading-ids"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
-
"@docusaurus/core": "2.0.0-beta.
|
18
|
-
"@docusaurus/preset-classic": "2.0.0-beta.
|
17
|
+
"@docusaurus/core": "^2.0.0-beta.20",
|
18
|
+
"@docusaurus/preset-classic": "^2.0.0-beta.20",
|
19
|
+
"@easyops-cn/docusaurus-search-local": "^0.25.0",
|
19
20
|
"@mdx-js/react": "^1.6.22",
|
20
21
|
"clsx": "^1.1.1",
|
21
22
|
"prism-react-renderer": "^1.3.1",
|