ransack 3.2.0 → 3.2.1

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
  SHA256:
3
- metadata.gz: 3f37dfefd63333903d6b36084a8dda1193ca31788777b2645d25b96dd97d2d2c
4
- data.tar.gz: dba86f7268c931801e1caf32f3552ebfeecc06fec2f773130118cc2c809c61e9
3
+ metadata.gz: f4ce966153aee54a3e24eb4ec775569926813ed7273839e5d042dbbc6b3addf8
4
+ data.tar.gz: 4d96b0ecae077f0096494a99f90e8cfb3555140fe194c79ed691b2760319e51c
5
5
  SHA512:
6
- metadata.gz: 7c8364c70e6536c5aa5dca37c5539164d89dab6fb9e582501dbf5611ff4a647aa0b5ff69450a0b4d480de4d61e62708b3c376ffb6813c0f06ff6b0a591c670f6
7
- data.tar.gz: 4681b4c7f4e03002b968e165abf930a6b42dfc1e4d740a0bb8a034a9c805b1f956d6f82ab5ca0e39117a8a08b8899b849e34ccf665ac5f7c36fd1aec83ebe3e5
6
+ metadata.gz: 5d23fb2ddc8ef40489c40e02202b3d051305252c21b5f6c2823478442ce326990b22a26ee46861212b690ada0632328ce6c5065cba238bd185eecc46fd5555c5
7
+ data.tar.gz: 5dffd2910eefdfe2633d13a4b7d36838340f45fb484f025fed264e5df5b69c730df16257f11e7425a0852f99255b1f22e970c6407a9f5f4c59c2ca027f6e8804
@@ -11,12 +11,12 @@ jobs:
11
11
  fail-fast: false
12
12
  matrix:
13
13
  rails:
14
- - v7.0.2
15
- - v6.1.5
14
+ - v7.0.3
15
+ - v6.1.6
16
16
  ruby:
17
- - 3.1.1
18
- - 3.0.2
19
- - 2.7.4
17
+ - 3.1.2
18
+ - 3.0.4
19
+ - 2.7.6
20
20
  env:
21
21
  DB: sqlite3
22
22
  RAILS: ${{ matrix.rails }}
@@ -37,12 +37,12 @@ jobs:
37
37
  fail-fast: false
38
38
  matrix:
39
39
  rails:
40
- - v7.0.2
41
- - v6.1.5
40
+ - v7.0.3
41
+ - v6.1.6
42
42
  ruby:
43
- - 3.1.1
44
- - 3.0.2
45
- - 2.7.4
43
+ - 3.1.2
44
+ - 3.0.4
45
+ - 2.7.6
46
46
  env:
47
47
  DB: mysql
48
48
  RAILS: ${{ matrix.rails }}
@@ -72,12 +72,12 @@ jobs:
72
72
  fail-fast: false
73
73
  matrix:
74
74
  rails:
75
- - v7.0.2
76
- - v6.1.5
75
+ - v7.0.3
76
+ - v6.1.6
77
77
  ruby:
78
- - 3.1.1
79
- - 3.0.2
80
- - 2.7.4
78
+ - 3.1.2
79
+ - 3.0.4
80
+ - 2.7.6
81
81
  env:
82
82
  DB: postgres
83
83
  RAILS: ${{ matrix.rails }}
@@ -120,7 +120,7 @@ jobs:
120
120
  - name: Set up Ruby
121
121
  uses: ruby/setup-ruby@v1
122
122
  with:
123
- ruby-version: 3.1.1
123
+ ruby-version: 3.1.2
124
124
  - name: Install dependencies
125
125
  run: bundle install
126
126
  - name: Run bug report templates
data/CHANGELOG.md CHANGED
@@ -2,13 +2,33 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.2.1 - 2022-05-24
6
+
7
+ * Add search functionality to documentation site.
8
+ PR [1329](https://github.com/activerecord-hackery/ransack/pull/1329)
9
+
10
+ * Fix contributing URLs and syntax highlight in `README.md`.
11
+ PR [1326](https://github.com/activerecord-hackery/ransack/pull/1326)
12
+
13
+ * Cast PostgreSQL's `timestamptz` columns to time.
14
+ PR [1325](https://github.com/activerecord-hackery/ransack/pull/1325)
15
+
16
+ * Add Ruby and ERB syntax highlighting support to documentation site.
17
+ PR [1324](https://github.com/activerecord-hackery/ransack/pull/1324)
18
+
19
+ * Fix a wrong link in `CHANGELOG.md`.
20
+ PR [1323](https://github.com/activerecord-hackery/ransack/pull/1323)
21
+
22
+ * Fix links to bug report templates in `CONTRIBUTING.md`.
23
+ PR [1321](https://github.com/activerecord-hackery/ransack/pull/1321)
24
+
5
25
  ## 3.2.0 - 2022-05-08
6
26
 
7
27
  * Drop Rails 6.0 support.
8
28
  PR [1318](https://github.com/activerecord-hackery/ransack/pull/1318)
9
29
 
10
30
  * Exclude "host" from params sent to url generator.
11
- PR [1319](https://github.com/activerecord-hackery/ransack/pull/1319)
31
+ PR [1317](https://github.com/activerecord-hackery/ransack/pull/1317)
12
32
 
13
33
  ## 3.1.0 - 2022-04-21
14
34
 
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:
@@ -123,7 +123,7 @@ Here's a quick guide:
123
123
 
124
124
  12. Push the branch up to your fork on GitHub
125
125
  (`git push origin my-new-feature`) and from GitHub submit a pull request to
126
- Ransack's `master` branch.
126
+ Ransack's `main` branch.
127
127
 
128
128
  At this point you're waiting on us. We like to at least comment on, if not
129
129
  accept, pull requests within three business days (and, typically, one business
data/README.md CHANGED
@@ -24,7 +24,7 @@ Ransack is supported for Rails 7.0, 6.x on Ruby 2.6.6 and later.
24
24
 
25
25
  To install `ransack` and add it to your Gemfile, run
26
26
 
27
- ```jsx title='Gemfile'
27
+ ```ruby title='Gemfile'
28
28
  gem 'ransack'
29
29
  ```
30
30
 
@@ -32,7 +32,7 @@ gem 'ransack'
32
32
 
33
33
  If you would like to use the latest updates not yet published to RubyGems, use the `main` branch:
34
34
 
35
- ```jsx title='Gemfile'
35
+ ```ruby title='Gemfile'
36
36
  gem 'ransack', :github => 'activerecord-hackery/ransack', :branch => 'main'
37
37
  ```
38
38
 
@@ -42,7 +42,7 @@ There is [extensive documentation on Ransack](https://activerecord-hackery.githu
42
42
 
43
43
  ## Issues tracker
44
44
 
45
- * Before filing an issue, please read the [Contributing Guide](https://github.com/activerecord-hackery/ransack/CONTRIBUTING.md).
45
+ * Before filing an issue, please read the [Contributing Guide](CONTRIBUTING.md).
46
46
  * 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
47
  * Please consider adding a branch with a failing spec describing the problem.
48
48
  * Contributions are welcome. :smiley:
@@ -58,7 +58,7 @@ To support the project:
58
58
  broken or missing. A failing spec to demonstrate the issue is awesome. A pull
59
59
  request with passing tests is even better!
60
60
  * 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).
61
+ [Contributing Guide](CONTRIBUTING.md).
62
62
  * Please use Stack Overflow or other sites for questions or discussion not
63
63
  directly related to bug reports, pull requests, or documentation improvements.
64
64
  * Spread the word on Twitter, Facebook, and elsewhere if Ransack's been useful
@@ -11,7 +11,7 @@ mode should meet your needs.
11
11
 
12
12
  ## In your controller
13
13
 
14
- ```jsx
14
+ ```ruby
15
15
  def index
16
16
  @q = Person.ransack(params[:q])
17
17
  @people = @q.result(distinct: true)
@@ -20,7 +20,7 @@ end
20
20
  or without `distinct: true`, for sorting on an associated table's columns (in
21
21
  this example, with preloading each Person's Articles and pagination):
22
22
 
23
- ```jsx
23
+ ```ruby
24
24
  def index
25
25
  @q = Person.ransack(params[:q])
26
26
  @people = @q.result.includes(:articles).page(params[:page])
@@ -35,7 +35,7 @@ Ransack uses a default `:q` param key for search params. This may be changed by
35
35
  setting the `search_key` option in a Ransack initializer file (typically
36
36
  `config/initializers/ransack.rb`):
37
37
 
38
- ```jsx
38
+ ```ruby
39
39
  Ransack.configure do |c|
40
40
  # Change default search parameter key name.
41
41
  # Default key name is :q
@@ -48,7 +48,7 @@ end
48
48
  After version 2.4.0 when searching a string query Ransack by default strips all whitespace around the query string.
49
49
  This may be disabled by setting the `strip_whitespace` option in a Ransack initializer file:
50
50
 
51
- ```jsx
51
+ ```ruby
52
52
  Ransack.configure do |c|
53
53
  # Change whitespace stripping behaviour.
54
54
  # Default is true
@@ -66,7 +66,7 @@ which are defined in
66
66
 
67
67
  Ransack's `search_form_for` helper replaces `form_for` for creating the view search form
68
68
 
69
- ```jsx
69
+ ```erb
70
70
  <%= search_form_for @q do |f| %>
71
71
 
72
72
  # Search if the name field contains...
@@ -95,7 +95,7 @@ search predicates.
95
95
 
96
96
  The `search_form_for` answer format can be set like this:
97
97
 
98
- ```jsx
98
+ ```erb
99
99
  <%= search_form_for(@q, format: :pdf) do |f| %>
100
100
 
101
101
  <%= search_form_for(@q, format: :json) do |f| %>
@@ -105,7 +105,7 @@ The `search_form_for` answer format can be set like this:
105
105
 
106
106
  Ransack's `sort_link` helper creates table headers that are sortable links
107
107
 
108
- ```jsx
108
+ ```erb
109
109
  <%= sort_link(@q, :name) %>
110
110
  ```
111
111
  Additional options can be passed after the column parameter, like a different
@@ -114,13 +114,13 @@ column title or a default sort order.
114
114
  If the first option after the column parameter is a String, it's considered a
115
115
  custom label for the link:
116
116
 
117
- ```jsx
117
+ ```erb
118
118
  <%= sort_link(@q, :name, 'Last Name', default_order: :desc) %>
119
119
  ```
120
120
 
121
121
  You can use a block if the link markup is hard to fit into the label parameter:
122
122
 
123
- ```jsx
123
+ ```erb
124
124
  <%= sort_link(@q, :name) do %>
125
125
  <strong>Player Name</strong>
126
126
  <% end %>
@@ -130,14 +130,14 @@ With a polymorphic association, you may need to specify the name of the link
130
130
  explicitly to avoid an `uninitialized constant Model::Xxxable` error (see issue
131
131
  [#421](https://github.com/activerecord-hackery/ransack/issues/421)):
132
132
 
133
- ```jsx
133
+ ```erb
134
134
  <%= sort_link(@q, :xxxable_of_Ymodel_type_some_attribute, 'Attribute Name') %>
135
135
  ```
136
136
 
137
137
  If the first option after the column parameter and/or the label parameter is an
138
138
  Array, it will be used for sorting on multiple fields:
139
139
 
140
- ```jsx
140
+ ```erb
141
141
  <%= sort_link(@q, :last_name, [:last_name, 'first_name asc'], 'Last Name') %>
142
142
  ```
143
143
 
@@ -148,7 +148,7 @@ Ransack to _always_ sort that particular field in the specified direction.
148
148
  Multiple `default_order` fields may also be specified with a trailing options
149
149
  Hash:
150
150
 
151
- ```jsx
151
+ ```erb
152
152
  <%= sort_link(@q, :last_name, %i(last_name first_name),
153
153
  default_order: { last_name: 'asc', first_name: 'desc' }) %>
154
154
  ```
@@ -162,7 +162,7 @@ of a SQL function, you may do so using scopes. In your model, define scopes
162
162
  whose names line up with the name of the virtual field you wish to sort by,
163
163
  as so:
164
164
 
165
- ```jsx
165
+ ```ruby
166
166
  class Person < ActiveRecord::Base
167
167
  scope :sort_by_reverse_name_asc, lambda { order("REVERSE(name) ASC") }
168
168
  scope :sort_by_reverse_name_desc, lambda { order("REVERSE(name) DESC") }
@@ -171,7 +171,7 @@ class Person < ActiveRecord::Base
171
171
 
172
172
  and you can then sort by this virtual field:
173
173
 
174
- ```jsx
174
+ ```erb
175
175
  <%= sort_link(@q, :reverse_name) %>
176
176
  ```
177
177
 
@@ -186,7 +186,7 @@ You can also enable a `default_arrow` which is displayed on all sortable fields
186
186
  which are not currently used in the sorting. This is disabled by default so
187
187
  nothing will be displayed:
188
188
 
189
- ```jsx
189
+ ```ruby
190
190
  Ransack.configure do |c|
191
191
  c.custom_arrows = {
192
192
  up_arrow: '<i class="custom-up-arrow-icon"></i>',
@@ -200,7 +200,7 @@ All sort links may be displayed without the order indicator
200
200
  arrows by setting `hide_sort_order_indicators` to true in the initializer file.
201
201
  Note that this hides the arrows even if they were customized:
202
202
 
203
- ```jsx
203
+ ```ruby
204
204
  Ransack.configure do |c|
205
205
  c.hide_sort_order_indicators = true
206
206
  end
@@ -209,7 +209,7 @@ end
209
209
  Without setting it globally, individual sort links may be displayed without
210
210
  the order indicator arrow by passing `hide_indicator: true` in the sort link:
211
211
 
212
- ```jsx
212
+ ```erb
213
213
  <%= sort_link(@q, :name, hide_indicator: true) %>
214
214
  ```
215
215
 
@@ -219,15 +219,15 @@ Ransack's `sort_url` helper is like a `sort_link` but returns only the url
219
219
 
220
220
  `sort_url` has the same API as `sort_link`:
221
221
 
222
- ```jsx
222
+ ```erb
223
223
  <%= sort_url(@q, :name, default_order: :desc) %>
224
224
  ```
225
225
 
226
- ```jsx
226
+ ```erb
227
227
  <%= sort_url(@q, :last_name, [:last_name, 'first_name asc']) %>
228
228
  ```
229
229
 
230
- ```jsx
230
+ ```erb
231
231
  <%= sort_url(@q, :last_name, %i(last_name first_name),
232
232
  default_order: { last_name: 'asc', first_name: 'desc' }) %>
233
233
  ```
@@ -238,7 +238,7 @@ The `NULLS FIRST` and `NULLS LAST` options can be used to determine whether null
238
238
 
239
239
  You may want to configure it like this:
240
240
 
241
- ```jsx
241
+ ```ruby
242
242
  Ransack.configure do |c|
243
243
  c.postgres_fields_sort_option = :nulls_first # or :nulls_last
244
244
  end
@@ -246,7 +246,7 @@ end
246
246
 
247
247
  To treat nulls as having the lowest or highest value respectively. To force nulls to always be first or last, use
248
248
 
249
- ```jsx
249
+ ```ruby
250
250
  Ransack.configure do |c|
251
251
  c.postgres_fields_sort_option = :nulls_always_first # or :nulls_always_last
252
252
  end
@@ -258,7 +258,7 @@ See this feature: https://www.postgresql.org/docs/13/queries-order.html
258
258
 
259
259
  In order to request PostgreSQL to do a case insensitive sort for all string columns of a model at once, Ransack can be extended by using this approach:
260
260
 
261
- ```jsx
261
+ ```ruby
262
262
  module RansackObject
263
263
 
264
264
  def self.included(base)
@@ -273,7 +273,7 @@ module RansackObject
273
273
  end
274
274
  ```
275
275
 
276
- ```jsx
276
+ ```ruby
277
277
  class UserWithManyAttributes < ActiveRecord::Base
278
278
  include RansackObject
279
279
  end
@@ -9,7 +9,7 @@ title: Sorting
9
9
 
10
10
  You can add a form to capture sorting and filtering options together.
11
11
 
12
- ```jsx
12
+ ```erb
13
13
  <div class="filters" id="filtersSidebar">
14
14
  <header class="filters-header">
15
15
  <div class="filters-header-content">
@@ -14,7 +14,7 @@ chances are you might want to search on tagged fields. Follow the instructions t
14
14
 
15
15
  You can call the tagging field anything you like, it just needs to be plural. No migration is needed as this is stored in the internal ActsAsTaggable tables (`tags` and `taggings`).
16
16
 
17
- ```rb
17
+ ```ruby
18
18
  class Task < ApplicationRecord
19
19
  acts_as_taggable_on :projects
20
20
  end
@@ -26,7 +26,7 @@ Add a field to strong params in the controller. Use the singular name with `_lis
26
26
 
27
27
  `app/controllers/tasks_controller.rb`
28
28
 
29
- ```rb
29
+ ```ruby
30
30
  def strong_params
31
31
  params
32
32
  .require(:tasks)
@@ -37,7 +37,7 @@ def strong_params
37
37
 
38
38
  We need to `send` the tag fieldname to our model, also using the singular naming.
39
39
 
40
- ```
40
+ ```erb
41
41
  <div class='form-group'>
42
42
  <%= f.label :project_list %>
43
43
  <%= f.text_field :project_list, value: @task.send(:project_list).to_s %>
@@ -50,7 +50,7 @@ Now we can collect our data via the form, with tags separated by commas.
50
50
 
51
51
  Imagine you have the following two instances of `Task`:
52
52
 
53
- ```rb
53
+ ```ruby
54
54
  { id: 1, name: 'Clean up my room', projects: [ 'Home', 'Personal' ] }
55
55
  { id: 2, name: 'Complete math exercises', projects: [ 'Homework', 'Study' ] }
56
56
  ```
@@ -97,7 +97,7 @@ In Option D we allow the user to select a list of valid tags and then search aga
97
97
 
98
98
  ActsAsTaggableOn allows scoping of tags based on another field on the model. Suppose we have a `language` field on the model, as an effective second level key. We would adjust our model to look like this:
99
99
 
100
- ```rb
100
+ ```ruby
101
101
  class Task < ApplicationRecord
102
102
  acts_as_taggable_on :projects
103
103
  acts_as_taggable_tenant :language
@@ -106,7 +106,7 @@ end
106
106
 
107
107
  The Ransack search is then filtered using the `for_tenant` method
108
108
 
109
- ```
109
+ ```erb
110
110
  <div class='form-group'>
111
111
  <%= f.label :projects_name, 'Project' %>
112
112
  <%= f.select :projects_name_in, ActsAsTaggableOn::Tag.for_tenant('fr').distinct.order(:name).pluck(:name) %>
@@ -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
- ```jsx title='index.html.erb'
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
- ```jsx title='user.rb'
33
+ ```ruby title='user.rb'
34
34
  require 'csv'
35
35
 
36
36
  class User < ApplicationRecord
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
- ```jsx title='Gemfile'
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
- ```jsx title='Gemfile'
28
+ ```ruby title='Gemfile'
29
29
  gem 'ransack', :github => 'activerecord-hackery/ransack', :branch => 'main'
30
30
  ```
31
31
 
@@ -15,7 +15,7 @@ const config = {
15
15
  favicon: 'img/favicon.ico',
16
16
  organizationName: 'activerecord-hackery',
17
17
  projectName: 'ransack',
18
- trailingSlash: false,
18
+ trailingSlash: true,
19
19
 
20
20
  presets: [
21
21
  [
@@ -100,8 +100,21 @@ const config = {
100
100
  prism: {
101
101
  theme: lightCodeTheme,
102
102
  darkTheme: darkCodeTheme,
103
+ additionalLanguages: ['ruby', 'erb'],
103
104
  },
104
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
+ ]
105
118
  };
106
119
 
107
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",
18
- "@docusaurus/preset-classic": "2.0.0-beta.18",
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",