You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a configuration object that handles names of Total and Per-Page
headers, as well as allows for the manual setting of the paginator that
ApiPagination will use. It's up to the user to make WillPaginate and
Kaminari play nicely together if they include both. Closes#33
Signed-off-by: David Celis <me@davidcel.is>
Copy file name to clipboardExpand all lines: README.md
+17-21Lines changed: 17 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,23 @@ gem 'will_paginate'
25
25
gem 'api-pagination'
26
26
```
27
27
28
+
## Configuration (optional)
29
+
30
+
By default, api-pagination will detect whether you're using Kaminari or WillPaginate, and name headers appropriately. If you want to change any of the configurable settings, you may do so:
31
+
32
+
```ruby
33
+
ApiPagination.configure do |config|
34
+
# If you have both gems included, you can choose a paginator.
35
+
config.paginator =:kaminari# or :will_paginate
36
+
37
+
# By default, this is set to 'Total'
38
+
config.total_header ='X-Total'
39
+
40
+
# By default, this is set to 'Per-Page'
41
+
config.per_page_header ='X-Per-Page'
42
+
end
43
+
```
44
+
28
45
## Rails
29
46
30
47
In your controller, provide a pageable collection to the `paginate` method. In its most convenient form, `paginate` simply mimics `render`:
@@ -116,27 +133,6 @@ Per-Page: 10
116
133
# ...
117
134
```
118
135
119
-
If you want, you can customize the name of `Total` and `Per-Page` headers.
120
-
All you need to do is to set the `total_header` or `per_page_header` on `ApiPagination`.
121
-
If nothing is setted it defaults to `Total` and `Per-Page`.
0 commit comments