1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00

Simplify sort_link code examples in README docs.

[skip ci]
This commit is contained in:
Jon Atack 2014-10-05 23:04:40 +02:00
parent 5c4962a02e
commit d2e185de4c

View file

@ -160,15 +160,13 @@ Additional options can be passed after the column attribute, like a different
column title or a default sort order:
```erb
<%= content_tag :th, sort_link(@q, :name, 'Last Name', default_order: :desc) %>
<%= sort_link(@q, :name, 'Last Name', default_order: :desc) %>
```
You can also sort on multiple fields by specifying an ordered array:
```erb
<%= content_tag :th, sort_link(
@q, :last_name, [:last_name, 'first_name asc'], 'Last Name'
) %>
<%= sort_link(@q, :last_name, [:last_name, 'first_name asc'], 'Last Name') %>
```
In the example above, clicking the link will sort by `last_name` and then
@ -178,9 +176,8 @@ Ransack to _always_ sort that particular field in the specified direction.
Multiple `default_order` fields may also be specified with a hash:
```erb
<%= sort_link(
@q, :last_name, [:last_name, :first_name], default_order: { last_name: 'asc', first_name: 'desc' }
) %>
<%= sort_link(@q, :last_name, [:last_name, :first_name],
default_order: { last_name: 'asc', first_name: 'desc' }) %>
```
This example toggles the sort directions of both fields, by default