Skip to content

Commit a02daba

Browse files
committed
Documentation site config
1 parent 1671f56 commit a02daba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+19928
-1039
lines changed

.nojekyll

Whitespace-only changes.

README.md

Lines changed: 43 additions & 1022 deletions
Large diffs are not rendered by default.

docs/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

docs/.nojekyll

Whitespace-only changes.

docs/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
slug: ransack-3-0-0
3+
title: Ransack 3.0.0
4+
authors:
5+
name: Sean Carroll
6+
title: Ransack Core Team
7+
tags: [ransack, release]
8+
---
9+
10+
Ransack has been a part of many Rubyists toolboxes for years and 3.0.0 is a major release. We have a number of new features and one breaking change. As part of 3.0.0, we decided to launch this documentation website, merging in the Wiki and the content from the README.
11+
12+
With 3.0.0 we are hoping to re-energise the community, we need help on closing out old issues, refactoring the codebase and even some design work.
13+
14+
I also wanted to let you know that Ernie Miller (creator of Ransack) has decided to leave the project completely, he has this message for the community:
15+
16+
> While my own personal development efforts have been spent elsewhere as of late, I'm keenly aware of how many people still depend on some of the software I originally wrote all those years ago.
17+
18+
> That's why I'm grateful to be able to step away from the ActiveRecord Hackery organization (and, specifically, maintenance of Ransack) without impacting those users. I'm thankful that Sean, David, Greg, and others will continue to support users, and wish them the best as they move forward without me!
19+
20+
Please join me in thanking Ernie for bringing Ransack to life, I personally think it is one of the most amazing Rails libraries out there.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Getting started",
3+
"position": 2
4+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
sidebar_position: 2
3+
title: Advanced Mode
4+
---
5+
6+
7+
"Advanced" searches Rails's nested attributes functionality in order to
8+
generate complex queries with nested AND/OR groupings, etc. This takes a bit
9+
more work but can generate some pretty cool search interfaces that put a lot of
10+
power in the hands of your users.
11+
12+
A notable drawback with these searches is
13+
that the increased size of the parameter string will typically force you to use
14+
the HTTP POST method instead of GET.
15+
16+
17+
## Tweak your routes
18+
19+
```ruby
20+
resources :people do
21+
collection do
22+
match 'search' => 'people#search', via: [:get, :post], as: :search
23+
end
24+
end
25+
```
26+
27+
## Add a controller action
28+
29+
```ruby
30+
def search
31+
index
32+
render :index
33+
end
34+
```
35+
36+
## Update your form
37+
38+
```erb
39+
<%= search_form_for @q, url: search_people_path,
40+
html: { method: :post } do |f| %>
41+
```
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
44+
construct much more complex search forms, such as the one on the
45+
[demo app](http://ransack-demo.herokuapp.com/users/advanced_search)
46+
(source code [here](https://github.com/activerecord-hackery/ransack_demo)).
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
sidebar_position: 3
3+
title: Configuration
4+
---
5+
6+
7+
8+
Ransack may be easily configured. The best place to put configuration is in an initializer file at `config/initializers/ransack.rb`, containing code such as:
9+
10+
```ruby
11+
Ransack.configure do |config|
12+
13+
# Change default search parameter key name.
14+
# Default key name is :q
15+
config.search_key = :query
16+
17+
# Raise errors if a query contains an unknown predicate or attribute.
18+
# Default is true (do not raise error on unknown conditions).
19+
config.ignore_unknown_conditions = false
20+
21+
# Globally display sort links without the order indicator arrow.
22+
# Default is false (sort order indicators are displayed).
23+
# This can also be configured individually in each sort link (see the README).
24+
config.hide_sort_order_indicators = true
25+
26+
end
27+
```
28+
29+
## Custom search parameter key name
30+
31+
Sometimes there are situations when the default search parameter name cannot be used, for instance,
32+
if there are two searches on one page. Another name may be set using the `search_key` option in the `ransack` or `search` methods in the controller, and in the `@search_form_for` method in the view.
33+
34+
### In the controller
35+
36+
```ruby
37+
@search = Log.ransack(params[:log_search], search_key: :log_search)
38+
# or
39+
@search = Log.search(params[:log_search], search_key: :log_search)
40+
```
41+
42+
### In the view
43+
44+
```erb
45+
<%= f.search_form_for @search, as: :log_search %>
46+
<%= sort_link(@search) %>
47+
```
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Search Matchers
3+
---
4+
5+
### Search Matchers
6+
7+
List of all possible predicates
8+
9+
10+
| Predicate | Description | Notes |
11+
| ------------- | ------------- |-------- |
12+
| `*_eq` | equal | |
13+
| `*_not_eq` | not equal | |
14+
| `*_matches` | matches with `LIKE` | e.g. `q[email_matches]=%@gmail.com`|
15+
| `*_does_not_match` | does not match with `LIKE` | |
16+
| `*_matches_any` | Matches any | |
17+
| `*_matches_all` | Matches all | |
18+
| `*_does_not_match_any` | Does not match any | |
19+
| `*_does_not_match_all` | Does not match all | |
20+
| `*_lt` | less than | |
21+
| `*_lteq` | less than or equal | |
22+
| `*_gt` | greater than | |
23+
| `*_gteq` | greater than or equal | |
24+
| `*_present` | not null and not empty | Only compatible with string columns. Example: `q[name_present]=1` (SQL: `col is not null AND col != ''`) |
25+
| `*_blank` | is null or empty. | (SQL: `col is null OR col = ''`) |
26+
| `*_null` | is null | |
27+
| `*_not_null` | is not null | |
28+
| `*_in` | match any values in array | e.g. `q[name_in][]=Alice&q[name_in][]=Bob` |
29+
| `*_not_in` | match none of values in array | |
30+
| `*_lt_any` | Less than any | SQL: `col < value1 OR col < value2` |
31+
| `*_lteq_any` | Less than or equal to any | |
32+
| `*_gt_any` | Greater than any | |
33+
| `*_gteq_any` | Greater than or equal to any | |
34+
| `*_lt_all` | Less than all | SQL: `col < value1 AND col < value2` |
35+
| `*_lteq_all` | Less than or equal to all | |
36+
| `*_gt_all` | Greater than all | |
37+
| `*_gteq_all` | Greater than or equal to all | |
38+
| `*_not_eq_all` | none of values in a set | |
39+
| `*_start` | Starts with | SQL: `col LIKE 'value%'` |
40+
| `*_not_start` | Does not start with | |
41+
| `*_start_any` | Starts with any of | |
42+
| `*_start_all` | Starts with all of | |
43+
| `*_not_start_any` | Does not start with any of | |
44+
| `*_not_start_all` | Does not start with all of | |
45+
| `*_end` | Ends with | SQL: `col LIKE '%value'` |
46+
| `*_not_end` | Does not end with | |
47+
| `*_end_any` | Ends with any of | |
48+
| `*_end_all` | Ends with all of | |
49+
| `*_not_end_any` | | |
50+
| `*_not_end_all` | | |
51+
| `*_cont` | Contains value | uses `LIKE` |
52+
| `*_cont_any` | Contains any of | |
53+
| `*_cont_all` | Contains all of | |
54+
| `*_not_cont` | Does not contain |
55+
| `*_not_cont_any` | Does not contain any of | |
56+
| `*_not_cont_all` | Does not contain all of | |
57+
| `*_i_cont` | Contains value with case insensitive | uses `ILIKE` |
58+
| `*_i_cont_any` | Contains any of values with case insensitive | |
59+
| `*_i_cont_all` | Contains all of values with case insensitive | |
60+
| `*_not_i_cont` | Does not contain with case insensitive |
61+
| `*_not_i_cont_any` | Does not contain any of values with case insensitive | |
62+
| `*_not_i_cont_all` | Does not contain all of values with case insensitive | |
63+
| `*_true` | is true | |
64+
| `*_false` | is false | |
65+
66+
67+
See full list: https://github.com/activerecord-hackery/ransack/blob/master/lib/ransack/locale/en.yml#L15

0 commit comments

Comments
 (0)