We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 26c3a60 commit a458c8fCopy full SHA for a458c8f
README.md
@@ -467,6 +467,25 @@ query parameters in your URLs.
467
<% end %>
468
```
469
470
+You can also use `ransack_alias` for sorting.
471
+
472
+```ruby
473
+class Post < ActiveRecord::Base
474
+ belongs_to :author
475
476
+ # Abbreviate :author_first_name to :author
477
+ ransack_alias :author, :author_first_name
478
+end
479
+```
480
481
+Now, you can use `:author` instead of `:author_first_name` in a `sort_link`.
482
483
+```erb
484
+<%= sort_link(@q, :author) %>
485
486
487
+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.
488
489
### Search Matchers
490
491
List of all possible predicates
0 commit comments