ransack 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql.yml +72 -0
  3. data/.github/workflows/test.yml +22 -27
  4. data/.rubocop.yml +3 -0
  5. data/CHANGELOG.md +79 -0
  6. data/CONTRIBUTING.md +38 -16
  7. data/Gemfile +10 -10
  8. data/README.md +8 -13
  9. data/bug_report_templates/test-ransacker-arel-present-predicate.rb +4 -0
  10. data/docs/docs/getting-started/advanced-mode.md +1 -1
  11. data/docs/docs/getting-started/search-matches.md +1 -1
  12. data/docs/docs/getting-started/simple-mode.md +30 -26
  13. data/docs/docs/getting-started/sorting.md +1 -1
  14. data/docs/docs/going-further/acts-as-taggable-on.md +10 -10
  15. data/docs/docs/going-further/exporting-to-csv.md +2 -2
  16. data/docs/docs/going-further/form-customisation.md +1 -1
  17. data/docs/docs/going-further/i18n.md +3 -3
  18. data/docs/docs/going-further/other-notes.md +1 -1
  19. data/docs/docs/going-further/saving-queries.md +1 -1
  20. data/docs/docs/going-further/searching-postgres.md +1 -1
  21. data/docs/docs/intro.md +2 -2
  22. data/docs/docusaurus.config.js +14 -1
  23. data/docs/package.json +7 -2
  24. data/docs/yarn.lock +3036 -1917
  25. data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +11 -1
  26. data/lib/ransack/adapters/active_record/base.rb +78 -7
  27. data/lib/ransack/adapters/active_record/context.rb +17 -49
  28. data/lib/ransack/configuration.rb +25 -12
  29. data/lib/ransack/constants.rb +125 -3
  30. data/lib/ransack/context.rb +34 -5
  31. data/lib/ransack/helpers/form_builder.rb +3 -3
  32. data/lib/ransack/helpers/form_helper.rb +4 -3
  33. data/lib/ransack/nodes/attribute.rb +2 -2
  34. data/lib/ransack/nodes/condition.rb +80 -7
  35. data/lib/ransack/nodes/grouping.rb +3 -3
  36. data/lib/ransack/nodes/node.rb +1 -1
  37. data/lib/ransack/nodes/value.rb +2 -2
  38. data/lib/ransack/predicate.rb +1 -1
  39. data/lib/ransack/ransacker.rb +1 -1
  40. data/lib/ransack/search.rb +9 -4
  41. data/lib/ransack/translate.rb +2 -2
  42. data/lib/ransack/version.rb +1 -1
  43. data/lib/ransack/visitor.rb +38 -2
  44. data/lib/ransack.rb +3 -6
  45. data/ransack.gemspec +2 -2
  46. data/spec/helpers/polyamorous_helper.rb +2 -8
  47. data/spec/ransack/adapters/active_record/base_spec.rb +73 -0
  48. data/spec/ransack/configuration_spec.rb +9 -9
  49. data/spec/ransack/helpers/form_builder_spec.rb +8 -8
  50. data/spec/ransack/helpers/form_helper_spec.rb +48 -2
  51. data/spec/ransack/nodes/condition_spec.rb +24 -0
  52. data/spec/ransack/nodes/value_spec.rb +115 -0
  53. data/spec/ransack/predicate_spec.rb +36 -1
  54. data/spec/ransack/translate_spec.rb +1 -1
  55. data/spec/support/schema.rb +27 -10
  56. metadata +11 -19
  57. data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +0 -20
  58. data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -79
  59. data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +0 -11
  60. data/lib/polyamorous.rb +0 -1
  61. data/lib/ransack/adapters/active_record/ransack/constants.rb +0 -128
  62. data/lib/ransack/adapters/active_record/ransack/context.rb +0 -56
  63. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +0 -69
  64. data/lib/ransack/adapters/active_record/ransack/translate.rb +0 -8
  65. data/lib/ransack/adapters/active_record/ransack/visitor.rb +0 -47
  66. data/lib/ransack/adapters.rb +0 -64
  67. data/lib/ransack/nodes.rb +0 -8
  68. /data/lib/ransack/{adapters/active_record.rb → active_record.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9db4893295fd342185cf668f2b3edbc59f1e649945024147778bdc52978e53fa
4
- data.tar.gz: 9f57ba51a61d63f1f4023735d8a2ef9384e7840461af65169f4c0214f4b619a8
3
+ metadata.gz: 39e79c778f9eacf124a0ae2465c586d016b8fc6dd934b889d9e7ac9ede798ea7
4
+ data.tar.gz: 45c34ad5656bd01fd03e9240cf60f7419c662ad0b9aba3a1340ae701844612db
5
5
  SHA512:
6
- metadata.gz: 625d61491c96bd319e95d65d0d704f3906b8087e21f8fd2f8f2d1515ac4debdd3e39b678bbea8f0d39d6a5e58d5b46ba66919cb8b4770c8bb7fc4a77421c743e
7
- data.tar.gz: cec0aa2875df4b9b8d5e8ae222fba9970ec0aaaf66de05ae21110a981828704a294f8f16fb55037ea0db39429611d7ea0e5f5d4ff51dbcd01cd66fca171b4ecf
6
+ metadata.gz: 7f8b2e4b1f4adaa8d1871879364d836c8a59fbc1b7342857a4d18c7406dd074d2b000380960e1b56555548968c866a109f7600090dc93cc533bc12b7cc52b6aa
7
+ data.tar.gz: 6b7c84bccd3ba55de586bb2ff58c5a95da5062e4c2046d00065289260af32a5b1991b21d7acad28f7d1e20cb75cde526126f7bef7f0296fead10395b95849af0
@@ -0,0 +1,72 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ main ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ main ]
20
+ schedule:
21
+ - cron: '43 11 * * 3'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+
52
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53
+ # queries: security-extended,security-and-quality
54
+
55
+
56
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57
+ # If this step fails, then you should remove it and run the build manually (see below)
58
+ - name: Autobuild
59
+ uses: github/codeql-action/autobuild@v2
60
+
61
+ # ℹ️ Command-line programs to run using the OS shell.
62
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63
+
64
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
65
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66
+
67
+ # - run: |
68
+ # echo "Run, Build Application using script"
69
+ # ./location_of_script_within_repo/buildscript.sh
70
+
71
+ - name: Perform CodeQL Analysis
72
+ uses: github/codeql-action/analyze@v2
@@ -2,6 +2,8 @@ name: test
2
2
 
3
3
  on:
4
4
  push:
5
+ branches:
6
+ - main
5
7
  pull_request:
6
8
 
7
9
  jobs:
@@ -11,13 +13,12 @@ jobs:
11
13
  fail-fast: false
12
14
  matrix:
13
15
  rails:
14
- - v7.0.2
15
- - v6.1.5
16
- - v6.0.4
16
+ - v7.0.3
17
+ - v6.1.6
17
18
  ruby:
18
- - 3.1.1
19
- - 3.0.2
20
- - 2.7.4
19
+ - 3.1.2
20
+ - 3.0.4
21
+ - 2.7.6
21
22
  env:
22
23
  DB: sqlite3
23
24
  RAILS: ${{ matrix.rails }}
@@ -27,8 +28,7 @@ jobs:
27
28
  uses: ruby/setup-ruby@v1
28
29
  with:
29
30
  ruby-version: ${{ matrix.ruby }}
30
- - name: Install dependencies
31
- run: bundle install
31
+ bundler-cache: true
32
32
  - name: Run tests
33
33
  run: bundle exec rspec
34
34
 
@@ -38,13 +38,12 @@ jobs:
38
38
  fail-fast: false
39
39
  matrix:
40
40
  rails:
41
- - v7.0.2
42
- - v6.1.5
43
- - v6.0.4
41
+ - v7.0.3
42
+ - v6.1.6
44
43
  ruby:
45
- - 3.1.1
46
- - 3.0.2
47
- - 2.7.4
44
+ - 3.1.2
45
+ - 3.0.4
46
+ - 2.7.6
48
47
  env:
49
48
  DB: mysql
50
49
  RAILS: ${{ matrix.rails }}
@@ -56,6 +55,7 @@ jobs:
56
55
  uses: ruby/setup-ruby@v1
57
56
  with:
58
57
  ruby-version: ${{ matrix.ruby }}
58
+ bundler-cache: true
59
59
  - name: Startup MySQL
60
60
  run: |
61
61
  sudo systemctl start mysql.service
@@ -63,8 +63,6 @@ jobs:
63
63
  run: |
64
64
  mysql --user=root --password=root --host=127.0.0.1 -e 'create database ransack collate utf8_general_ci;';
65
65
  mysql --user=root --password=root --host=127.0.0.1 -e 'use ransack;show variables like "%character%";show variables like "%collation%";';
66
- - name: Install dependencies
67
- run: bundle install
68
66
  - name: Run tests
69
67
  run: bundle exec rspec
70
68
 
@@ -74,13 +72,12 @@ jobs:
74
72
  fail-fast: false
75
73
  matrix:
76
74
  rails:
77
- - v7.0.2
78
- - v6.1.5
79
- - v6.0.4
75
+ - v7.0.3
76
+ - v6.1.6
80
77
  ruby:
81
- - 3.1.1
82
- - 3.0.2
83
- - 2.7.4
78
+ - 3.1.2
79
+ - 3.0.4
80
+ - 2.7.6
84
81
  env:
85
82
  DB: postgres
86
83
  RAILS: ${{ matrix.rails }}
@@ -108,11 +105,10 @@ jobs:
108
105
  uses: ruby/setup-ruby@v1
109
106
  with:
110
107
  ruby-version: ${{ matrix.ruby }}
108
+ bundler-cache: true
111
109
  - name: Setup databases
112
110
  run: |
113
111
  psql -h localhost -p 5432 -W postgres -c 'create database ransack;' -U postgres;
114
- - name: Install dependencies
115
- run: bundle install
116
112
  - name: Run tests
117
113
  run: bundle exec rspec
118
114
 
@@ -123,9 +119,8 @@ jobs:
123
119
  - name: Set up Ruby
124
120
  uses: ruby/setup-ruby@v1
125
121
  with:
126
- ruby-version: 3.1.1
127
- - name: Install dependencies
128
- run: bundle install
122
+ ruby-version: 3.1.2
123
+ bundler-cache: true
129
124
  - name: Run bug report templates
130
125
  run: |
131
126
  ruby bug_report_templates/test-ransacker-arel-present-predicate.rb
data/.rubocop.yml CHANGED
@@ -30,6 +30,9 @@ Layout/SpaceInsideParens:
30
30
  Layout/TrailingEmptyLines:
31
31
  Enabled: true
32
32
 
33
+ Style/HashSyntax:
34
+ Enabled: true
35
+
33
36
  Style/RedundantFileExtensionInRequire:
34
37
  Enabled: true
35
38
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,85 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.0.0 - 2023-02-09
6
+
7
+ ### 💥 Breaking Changes
8
+
9
+ * **[SECURITY]** Require explict allowlisting of attributes and associations by @deivid-rodriguez in https://github.com/activerecord-hackery/ransack/pull/1400
10
+ * Remove Polyamorous entrypoint by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1370
11
+ * Remove dead MongoDB code by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1345
12
+
13
+ ### 🚀 Features
14
+
15
+ * Add support for default predicates by @p8 in https://github.com/activerecord-hackery/ransack/pull/1384
16
+
17
+ ### 🐛 Bug Fixes
18
+
19
+ * Ignore `ActiveModel::RangeError` in Ransack conditions by @JunichiIto in https://github.com/activerecord-hackery/ransack/pull/1340
20
+ * Fix crash when using `q=string` as parameter by @stereobooster in https://github.com/activerecord-hackery/ransack/pull/1374
21
+ * Prevent changing host through params by @AndersGM in https://github.com/activerecord-hackery/ransack/pull/1391
22
+
23
+ ### 📝 Documentation
24
+
25
+ * Fix broken documentation link by @cpgo in https://github.com/activerecord-hackery/ransack/pull/1332
26
+ * Remove more old wiki references by @deivid-rodriguez in https://github.com/activerecord-hackery/ransack/pull/1333
27
+ * Improve some wording and correct some typos by @ydah in https://github.com/activerecord-hackery/ransack/pull/1336
28
+ * Add warning about necessary authorization by @AmShaegar13 in https://github.com/activerecord-hackery/ransack/pull/1367
29
+ * Fix required Ruby and Rails version in README by @tagliala in https://github.com/activerecord-hackery/ransack/pull/1389
30
+
31
+ ### 💅 Polish
32
+
33
+ * Implement CodeQL by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1334
34
+ * Code quality improvements by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1371
35
+ * Refactor adapters by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1348
36
+ * Fix typo: teh -> the by @jdufresne in https://github.com/activerecord-hackery/ransack/pull/1387
37
+ * Fix broken link by @maful in https://github.com/activerecord-hackery/ransack/pull/1394
38
+
39
+ ### 🏠 Internal
40
+
41
+ * Bump docusaurus by @deivid-rodriguez in https://github.com/activerecord-hackery/ransack/pull/1338
42
+ * Update dependencies by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1342
43
+ * Improve CI by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1351
44
+ * Improve CONTRIBUTING.md by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1347
45
+ * Add links to GitHub Discussions by @scarroll32 in https://github.com/activerecord-hackery/ransack/pull/1353
46
+ * Bump terser from 5.14.0 to 5.14.2 in /docs by @dependabot in https://github.com/activerecord-hackery/ransack/pull/1355
47
+ * Bump loader-utils from 2.0.2 to 2.0.3 in /docs by @dependabot in https://github.com/activerecord-hackery/ransack/pull/1372
48
+ * Bump loader-utils from 2.0.3 to 2.0.4 in /docs by @dependabot in https://github.com/activerecord-hackery/ransack/pull/1378
49
+ * Upgrade some documentation dependencies by @deivid-rodriguez in https://github.com/activerecord-hackery/ransack/pull/1379
50
+ * Upgrade local search plugin too by @deivid-rodriguez in https://github.com/activerecord-hackery/ransack/pull/1380
51
+ * Bump json5 from 2.2.1 to 2.2.3 in /docs by @dependabot in https://github.com/activerecord-hackery/ransack/pull/1390
52
+ * Bump ua-parser-js from 0.7.31 to 0.7.33 in /docs by @dependabot in https://github.com/activerecord-hackery/ransack/pull/1397
53
+ * Bump some doc deps by @deivid-rodriguez in https://github.com/activerecord-hackery/ransack/pull/1398
54
+ * Bump http-cache-semantics from 4.1.0 to 4.1.1 in /docs by @dependabot in https://github.com/activerecord-hackery/ransack/pull/1401
55
+
56
+ ## 3.2.1 - 2022-05-24
57
+
58
+ * Add search functionality to documentation site.
59
+ PR [1329](https://github.com/activerecord-hackery/ransack/pull/1329)
60
+
61
+ * Fix contributing URLs and syntax highlight in `README.md`.
62
+ PR [1326](https://github.com/activerecord-hackery/ransack/pull/1326)
63
+
64
+ * Cast PostgreSQL's `timestamptz` columns to time.
65
+ PR [1325](https://github.com/activerecord-hackery/ransack/pull/1325)
66
+
67
+ * Add Ruby and ERB syntax highlighting support to documentation site.
68
+ PR [1324](https://github.com/activerecord-hackery/ransack/pull/1324)
69
+
70
+ * Fix a wrong link in `CHANGELOG.md`.
71
+ PR [1323](https://github.com/activerecord-hackery/ransack/pull/1323)
72
+
73
+ * Fix links to bug report templates in `CONTRIBUTING.md`.
74
+ PR [1321](https://github.com/activerecord-hackery/ransack/pull/1321)
75
+
76
+ ## 3.2.0 - 2022-05-08
77
+
78
+ * Drop Rails 6.0 support.
79
+ PR [1318](https://github.com/activerecord-hackery/ransack/pull/1318)
80
+
81
+ * Exclude "host" from params sent to url generator.
82
+ PR [1317](https://github.com/activerecord-hackery/ransack/pull/1317)
83
+
5
84
  ## 3.1.0 - 2022-04-21
6
85
 
7
86
  * Fix predicate name in "Using Predicates" documentation page.
data/CONTRIBUTING.md CHANGED
@@ -20,14 +20,14 @@ Steps:
20
20
  reported.
21
21
 
22
22
  2. **Check if the issue has been fixed** — try to reproduce it using the
23
- `master` branch in the repository.
23
+ `main` branch in the repository.
24
24
 
25
25
  3. **Isolate the real problem** — make sure the issue is really a bug in
26
26
  Ransack and not in your code or another gem.
27
27
 
28
28
  4. **Report the issue** by providing the link to a self-contained
29
- gist like [this](https://github.com/activerecord-hackery/ransack/blob/run_bug_report_templates/bug_report_templates/test-ransack-scope-and-column-same-name.rb) or
30
- [this](https://github.com/activerecord-hackery/ransack/blob/run_bug_report_templates/bug_report_templates/test-ransacker-arel-present-predicate.rb). Please use
29
+ gist like [this](https://github.com/activerecord-hackery/ransack/blob/main/bug_report_templates/test-ransack-scope-and-column-same-name.rb) or
30
+ [this](https://github.com/activerecord-hackery/ransack/blob/main/bug_report_templates/test-ransacker-arel-present-predicate.rb). Please use
31
31
  these code examples as a bug-report template for your Ransack issue!
32
32
 
33
33
  If you do not provide a self-contained gist and would like your issue to be reviewed, do provide at a minimum:
@@ -64,36 +64,56 @@ Here's a quick guide:
64
64
  2. Create a thoughtfully-named branch for your changes (`git checkout -b my-new-feature`).
65
65
 
66
66
  3. Install the development dependencies by running `bundle install`.
67
- To install rails other than latest (set in Gemfile): `RAILS='6-0-stable' bundle install`
67
+ To install rails other than latest (set in Gemfile): `RAILS='6-1-stable' bundle install`
68
68
 
69
69
  4. Begin by running the tests. We only take pull requests with passing tests,
70
70
  and it's great to know that you have a clean slate:
71
71
 
72
- $ bundle exec rake spec
72
+ ```sh
73
+ bundle exec rake spec
74
+ ```
73
75
 
74
76
  The test suite runs by default with SQLite3. To run the test suite with PostgreSQL or MySQL, use:
75
77
 
76
- $ DB=pg bundle exec rake spec (`DB=postgres` & `DB=postgresql` work too)
77
- $ DB=mysql bundle exec rake spec
78
+ ```sh
79
+ DB=pg bundle exec rake spec
80
+ DB=mysql bundle exec rake spec
81
+ ```
82
+
83
+ A one-liner to run all three
84
+
85
+ ```sh
86
+ bundle exec rake spec && DB=pg bundle exec rake spec && DB=mysql bundle exec rake spec
87
+ ```
78
88
 
79
89
  For Postgres and MySQL, databases are expected to exist, called 'ransack'. To create use these commands (assuming OS X and Homebrew):
80
90
 
81
91
  ### Postgres
82
- $ createdb ransack
92
+
93
+ ```sh
94
+ createdb ransack
95
+ ```
83
96
 
84
97
  ### MySQL
85
- $ mysql -u root
86
- mysql> create database ransack;
98
+
99
+ ```sh
100
+ mysql -u root
101
+ mysql> create database ransack;
102
+ ```
87
103
 
88
104
  The test suite runs by default
89
105
 
90
106
  To run only the tests in a particular file: `bundle exec rspec <path/to/filename>`
91
107
 
92
- $ bundle exec rspec spec/ransack/search_spec.rb
108
+ ```sh
109
+ bundle exec rspec spec/ransack/search_spec.rb
110
+ ```
93
111
 
94
112
  To run a single test in that file: `bundle exec rspec <path/to/filename> -e "test name"`
95
113
 
96
- $ bundle exec rspec spec/ransack/search_spec.rb -e "accepts a context option"
114
+ ```sh
115
+ bundle exec rspec spec/ransack/search_spec.rb -e "accepts a context option"
116
+ ```
97
117
 
98
118
  5. Hack away! Please use Ruby features that are compatible down to Ruby 2.3.
99
119
  Since version 2.3.1, Ransack no longer maintains Ruby 2.2 compatibility.
@@ -109,8 +129,10 @@ Here's a quick guide:
109
129
 
110
130
  9. Make sure git knows your name and email address in your `~/.gitconfig` file:
111
131
 
112
- $ git config --global user.name "Your Name"
113
- $ git config --global user.email "contributor@example.com"
132
+ ```sh
133
+ git config --global user.name "Your Name"
134
+ git config --global user.email "contributor@example.com"
135
+ ```
114
136
 
115
137
  10. Commit your changes (`git commit -am 'Add feature/fix bug/improve docs'`).
116
138
  If your pull request only contains documentation changes, please remember
@@ -123,7 +145,7 @@ Here's a quick guide:
123
145
 
124
146
  12. Push the branch up to your fork on GitHub
125
147
  (`git push origin my-new-feature`) and from GitHub submit a pull request to
126
- Ransack's `master` branch.
148
+ Ransack's `main` branch.
127
149
 
128
150
  At this point you're waiting on us. We like to at least comment on, if not
129
151
  accept, pull requests within three business days (and, typically, one business
@@ -132,7 +154,7 @@ day). We may suggest some changes or improvements or alternatives.
132
154
  Some things that will increase the chance that your pull request is accepted:
133
155
 
134
156
  * Include tests that fail without your code, and pass with it.
135
- * Update the README, the change log, the wiki documentation... anything that is
157
+ * Update the README, the change log, the documentation... anything that is
136
158
  affected by your contribution.
137
159
  * Use idiomatic Ruby and follow the syntax conventions below.
138
160
 
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  gem 'rake'
5
5
 
6
- rails = ENV['RAILS'] || '6-0-stable'
6
+ rails = ENV['RAILS'] || '6-1-stable'
7
7
 
8
8
  rails_version = case rails
9
9
  when /\// # A path
@@ -14,10 +14,10 @@ rails_version = case rails
14
14
  rails
15
15
  end
16
16
 
17
- gem 'faker', '~> 2.0'
18
- gem 'sqlite3', ::Gem::Version.new(rails_version == 'main' ? '6.2.0.alpha' : rails_version) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
19
- gem 'pg', '~> 1.0'
20
- gem 'pry', '~> 0.12.2'
17
+ gem 'faker'
18
+ gem 'sqlite3'
19
+ gem 'pg'
20
+ gem 'pry'
21
21
  gem 'byebug'
22
22
 
23
23
  case rails
@@ -28,26 +28,26 @@ when /\// # A path
28
28
  gem 'actionpack', path: "#{rails}/actionpack"
29
29
  gem 'actionview', path: "#{rails}/actionview"
30
30
  when /^v/ # A tagged version
31
- git 'https://github.com/rails/rails.git', :tag => rails do
31
+ git 'https://github.com/rails/rails.git', tag: rails do
32
32
  gem 'activesupport'
33
33
  gem 'activemodel'
34
34
  gem 'activerecord', require: false
35
35
  gem 'actionpack'
36
36
  end
37
37
  else
38
- git 'https://github.com/rails/rails.git', :branch => rails do
38
+ git 'https://github.com/rails/rails.git', branch: rails do
39
39
  gem 'activesupport'
40
40
  gem 'activemodel'
41
41
  gem 'activerecord', require: false
42
42
  gem 'actionpack'
43
43
  end
44
44
  end
45
- gem 'mysql2', '~> 0.5.2'
45
+ gem 'mysql2'
46
46
 
47
47
  group :test do
48
48
  gem 'machinist', '~> 1.0.6'
49
- gem 'rspec', '~> 3'
50
- gem 'simplecov', :require => false
49
+ gem 'rspec'
50
+ gem 'simplecov', require: false
51
51
  end
52
52
 
53
53
  gem 'rubocop', require: false
data/README.md CHANGED
@@ -5,11 +5,6 @@
5
5
  [![Code Climate](https://codeclimate.com/github/activerecord-hackery/ransack/badges/gpa.svg)](https://codeclimate.com/github/activerecord-hackery/ransack)
6
6
  [![Backers on Open Collective](https://opencollective.com/ransack/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/ransack/sponsors/badge.svg)](#sponsors)
7
7
 
8
- # SPECIAL ANNOUNCEMENT
9
-
10
- Please see the [Ransack Blog](https://activerecord-hackery.github.io/ransack/blog) for a special announcement from the Ransack maintainers and Ernie Miller, the original author of Ransack.
11
-
12
-
13
8
  # Introduction
14
9
 
15
10
  Ransack will help you easily add **searching to your Rails application**, without any additional dependencies.
@@ -18,13 +13,13 @@ There are advanced searching solutions around, like ElasticSearch or Algolia. **
18
13
 
19
14
  Ready to move beyond the basics? Use **advanced features** like i18n and extensive configuration options.
20
15
 
21
- Ransack is supported for Rails 7.0, 6.x on Ruby 2.6.6 and later.
16
+ Ransack is supported for Rails 7.0, 6.1 on Ruby 2.7 and later.
22
17
 
23
18
  ## Installation
24
19
 
25
20
  To install `ransack` and add it to your Gemfile, run
26
21
 
27
- ```jsx title='Gemfile'
22
+ ```ruby title='Gemfile'
28
23
  gem 'ransack'
29
24
  ```
30
25
 
@@ -32,7 +27,7 @@ gem 'ransack'
32
27
 
33
28
  If you would like to use the latest updates not yet published to RubyGems, use the `main` branch:
34
29
 
35
- ```jsx title='Gemfile'
30
+ ```ruby title='Gemfile'
36
31
  gem 'ransack', :github => 'activerecord-hackery/ransack', :branch => 'main'
37
32
  ```
38
33
 
@@ -42,11 +37,11 @@ There is [extensive documentation on Ransack](https://activerecord-hackery.githu
42
37
 
43
38
  ## Issues tracker
44
39
 
45
- * Before filing an issue, please read the [Contributing Guide](https://github.com/activerecord-hackery/ransack/CONTRIBUTING.md).
40
+ * Before filing an issue, please read the [Contributing Guide](CONTRIBUTING.md).
46
41
  * File an issue if a bug is caused by Ransack, is new (has not already been reported), and _can be reproduced from the information you provide_.
47
42
  * Please consider adding a branch with a failing spec describing the problem.
48
43
  * Contributions are welcome. :smiley:
49
- * Please do not use the issue tracker for personal support requests. Stack Overflow is a better place for that where a wider community can help you!
44
+ * Please do not use the issue tracker for personal support requests. Stack Overflow or [GitHub Discussions](https://github.com/activerecord-hackery/ransack/discussions) is a better place for that where a wider community can help you!
50
45
 
51
46
 
52
47
  ## Contributions
@@ -58,10 +53,10 @@ To support the project:
58
53
  broken or missing. A failing spec to demonstrate the issue is awesome. A pull
59
54
  request with passing tests is even better!
60
55
  * Before filing an issue or pull request, be sure to read and follow the
61
- [Contributing Guide](https://github.com/activerecord-hackery/ransack/CONTRIBUTING.md).
62
- * Please use Stack Overflow or other sites for questions or discussion not
56
+ [Contributing Guide](CONTRIBUTING.md).
57
+ * Please use Stack Overflow or [GitHub Discussions](https://github.com/activerecord-hackery/ransack/discussions) for questions or discussion not
63
58
  directly related to bug reports, pull requests, or documentation improvements.
64
- * Spread the word on Twitter, Facebook, and elsewhere if Ransack's been useful
59
+ * Spread the word on social media if Ransack's been useful
65
60
  to you. The more people who are using the project, the quicker we can find and
66
61
  fix bugs!
67
62
 
@@ -56,6 +56,10 @@ class Project < ActiveRecord::Base
56
56
  ransacker :number do |parent|
57
57
  parent.table[:number]
58
58
  end
59
+
60
+ def self.ransackable_attributes(_auth_object = nil)
61
+ ["name", "number"]
62
+ end
59
63
  end
60
64
 
61
65
  class BugTest < Minitest::Test
@@ -40,7 +40,7 @@ end
40
40
  html: { method: :post } do |f| %>
41
41
  ```
42
42
 
43
- Once you've done so, you can make use of the helpers in [Ransack::Helpers::FormBuilder](https://github.com/activerecord-hackery/ransack/lib/ransack/helpers/form_builder.rb) to
43
+ Once you've done so, you can make use of the helpers in [Ransack::Helpers::FormBuilder](https://github.com/activerecord-hackery/ransack/blob/main/lib/ransack/helpers/form_builder.rb) to
44
44
  construct much more complex search forms, such as the one on the
45
45
  [demo app](http://ransack-demo.herokuapp.com/users/advanced_search)
46
46
  (source code [here](https://github.com/activerecord-hackery/ransack_demo)).
@@ -64,4 +64,4 @@ List of all possible predicates
64
64
  | `*_false` | is false | |
65
65
 
66
66
 
67
- See full list: https://github.com/activerecord-hackery/ransack/blob/master/lib/ransack/locale/en.yml#L15
67
+ See full list: https://github.com/activerecord-hackery/ransack/blob/main/lib/ransack/locale/en.yml#L16