sortabl 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/sortabl/sortabl_helper.rb +1 -1
- data/lib/sortabl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1490175b83dc4c1ecf163ed9d46d0d07a9f4f08
|
4
|
+
data.tar.gz: 5320c74587adf23634d65b16b89cb600e6d03f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01c673da47ab2844dd0ad60fb7feaae55f6e50d8cdb1c3c0d4c84e920311b8dc6346a17c59e92453b44d43e3bfa8ba9c27c5aafe2b509b9109e0bdbb89d93835
|
7
|
+
data.tar.gz: b0ce7e421845e877429781953677cfb8890aa68d02ff174c32051b5392c9d4389130012edb0810f5ef8e712020f77c0e12553363d8d1ffc4e11dbececf62d170
|
data/README.md
CHANGED
@@ -18,13 +18,13 @@ gem 'sortabl'
|
|
18
18
|
@posts = Post.sortabl(sort_by: params[:sort])
|
19
19
|
```
|
20
20
|
|
21
|
-
And that's it! Records will be sorted by permitted parameter `:sort`. If parameter `:sort` isn't permitted, records will be sorted by primary key.
|
21
|
+
And that's it! Records will be sorted by permitted parameter `:sort`. If parameter `:sort` isn't permitted, records will be sorted by primary key. If you don't want to sort by primary key by default, you can set another one by:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
@posts = Post.
|
24
|
+
@posts = Post.sortabl(sort_by: params[:sort], default: :author)
|
25
25
|
```
|
26
26
|
|
27
|
-
Permitted values can be
|
27
|
+
Permitted values can be an attribute of model class, followed by `_asc` or `_desc`. For example: `sort: :author_asc`
|
28
28
|
If there's an attribute permitted which doesn't exist in model, it falls back to sort by `default` key. Attributes can be limited with `only` and `except`. For example:
|
29
29
|
|
30
30
|
```ruby
|
@@ -41,7 +41,7 @@ There's also a view helper for rendering table heads:
|
|
41
41
|
```erb
|
42
42
|
<table>
|
43
43
|
<thead>
|
44
|
-
<%=
|
44
|
+
<%= sortabl_th 'Author', :author, id: 'author-column', class: 'author-column' %>
|
45
45
|
</thead>
|
46
46
|
<tbody>
|
47
47
|
...
|
@@ -6,7 +6,7 @@ module Sortabl
|
|
6
6
|
# Uses fontawesome as default icons
|
7
7
|
# <th 'data-sortable': 'attribute_direction'>Name <i class='fa fa-...'></th>
|
8
8
|
#
|
9
|
-
def
|
9
|
+
def sortabl_th name, attribute, *args
|
10
10
|
|
11
11
|
# To provide full path with all given params
|
12
12
|
# make a copy of incoming params and override sort_param only
|
data/lib/sortabl/version.rb
CHANGED