Update README.md

This commit is contained in:
Waldyr de Souza 2021-07-05 16:47:37 +02:00 committed by GitHub
parent 26c3a605a8
commit a458c8fe2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -467,6 +467,25 @@ query parameters in your URLs.
<% end %>
```
You can also use `ransack_alias` for sorting.
```ruby
class Post < ActiveRecord::Base
belongs_to :author
# Abbreviate :author_first_name to :author
ransack_alias :author, :author_first_name
end
```
Now, you can use `:author` instead of `:author_first_name` in a `sort_link`.
```erb
<%= sort_link(@q, :author) %>
```
Note that using `:author_first_name_or_author_last_name_cont` would produce an invalid sql query. In those cases, Ransack ignores the sorting clause.
### Search Matchers
List of all possible predicates