Skip to content

Commit 437a578

Browse files
authored
Merge pull request #779 from aspirewit/improve-docs
[skip ci] Improve docs
2 parents 8ca8c95 + d2c015d commit 437a578

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
[![Code Climate](https://codeclimate.com/github/activerecord-hackery/ransack/badges/gpa.svg)]
88
(https://codeclimate.com/github/activerecord-hackery/ransack)
99

10-
Ransack is a rewrite of [MetaSearch]
11-
(https://github.com/activerecord-hackery/meta_search)
10+
Ransack is a rewrite of [MetaSearch](https://github.com/activerecord-hackery/meta_search)
1211
created by [Ernie Miller](http://twitter.com/erniemiller)
1312
and developed/maintained for years by
1413
[Jon Atack](http://twitter.com/jonatack) and
1514
[Ryan Bigg](http://twitter.com/ryanbigg) with the help of a great group of
16-
[contributors]
17-
(https://github.com/activerecord-hackery/ransack/graphs/contributors).
15+
[contributors](https://github.com/activerecord-hackery/ransack/graphs/contributors).
1816
While it supports many of the same features as MetaSearch, its underlying
1917
implementation differs greatly from MetaSearch,
2018
and backwards compatibility is not a design goal.
@@ -80,8 +78,7 @@ If you're coming from MetaSearch, things to note:
8078
1. The default param key for search params is now `:q`, instead of `:search`.
8179
This is primarily to shorten query strings, though advanced queries (below)
8280
will still run afoul of URL length limits in most browsers and require a
83-
switch to HTTP POST requests. This key is [configurable]
84-
(https://github.com/activerecord-hackery/ransack/wiki/Configuration).
81+
switch to HTTP POST requests. This key is [configurable](https://github.com/activerecord-hackery/ransack/wiki/Configuration).
8582

8683
2. `form_for` is now `search_form_for`, and validates that a Ransack::Search
8784
object is passed to it.
@@ -91,7 +88,7 @@ If you're coming from MetaSearch, things to note:
9188
ActiveRecord::Relation in the case of the ActiveRecord adapter) via a call to
9289
`Ransack#result`.
9390

94-
####In your controller
91+
#### In your controller
9592

9693
```ruby
9794
def index
@@ -112,13 +109,13 @@ def index
112109
end
113110
```
114111

115-
####In your view
112+
#### In your view
116113

117114
The two primary Ransack view helpers are `search_form_for` and `sort_link`,
118115
which are defined in
119116
[Ransack::Helpers::FormHelper](lib/ransack/helpers/form_helper.rb).
120117

121-
####Ransack's `search_form_for` helper replaces `form_for` for creating the view search form
118+
#### Ransack's `search_form_for` helper replaces `form_for` for creating the view search form
122119

123120
```erb
124121
<%= search_form_for @q do |f| %>
@@ -154,7 +151,7 @@ The `search_form_for` answer format can be set like this:
154151
<%= search_form_for(@q, format: :json) do |f| %>
155152
```
156153

157-
####Ransack's `sort_link` helper creates table headers that are sortable links
154+
#### Ransack's `sort_link` helper creates table headers that are sortable links
158155

159156
```erb
160157
<%= sort_link(@q, :name) %>
@@ -234,7 +231,7 @@ the order indicator arrow by passing `hide_indicator: true` in the sort link:
234231
<%= sort_link(@q, :name, hide_indicator: true) %>
235232
```
236233

237-
####Ransack's `sort_url` helper is like a `sort_link` but returns only the url
234+
#### Ransack's `sort_url` helper is like a `sort_link` but returns only the url
238235

239236
`sort_url` has the same API as `sort_link`:
240237

@@ -443,8 +440,7 @@ List of all possible predicates
443440
The main premise behind Ransack is to provide access to
444441
**Arel predicate methods**. Ransack provides special methods, called
445442
_ransackers_, for creating additional search functions via Arel. More
446-
information about `ransacker` methods can be found [here in the wiki]
447-
(https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers).
443+
information about `ransacker` methods can be found [here in the wiki](https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers).
448444
Feel free to contribute working `ransacker` code examples to the wiki!
449445

450446
### Problem with DISTINCT selects
@@ -554,8 +550,7 @@ for an `auth_object` key in the options hash which can be used by your own
554550
overridden methods.
555551

556552
Here is an example that puts all this together, adapted from
557-
[this blog post by Ernie Miller]
558-
(http://erniemiller.org/2012/05/11/why-your-ruby-class-macros-might-suck-mine-did/).
553+
[this blog post by Ernie Miller](http://erniemiller.org/2012/05/11/why-your-ruby-class-macros-might-suck-mine-did/).
559554
In an `Article` model, add the following `ransackable_attributes` class method
560555
(preferably private):
561556

@@ -679,8 +674,7 @@ argument are not easily usable yet, because the array currently needs to be
679674
wrapped in an array to function (see
680675
[this issue](https://github.com/activerecord-hackery/ransack/issues/404)),
681676
which is not compatible with Ransack form helpers. For this use case, it may be
682-
better for now to use [ransackers]
683-
(https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers) instead,
677+
better for now to use [ransackers](https://github.com/activerecord-hackery/ransack/wiki/Using-Ransackers) instead,
684678
where feasible. Pull requests with solutions and tests are welcome!
685679

686680
### Grouping queries by OR instead of AND

0 commit comments

Comments
 (0)