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
Current implementation based on Kaminari and compatible with it model scoped config options.
123
+
You can use it independently of Kaminari or WillPaginate.
124
+
125
+
Just use `cursor_paginate` method instead of `pagination`:
126
+
127
+
def cast
128
+
actors = Movie.find(params[:id]).actors
129
+
cursor_paginate json: actors, per_page: 10
130
+
end
131
+
132
+
You can configure the following default values by overriding these values using `Cursor.configure` method.
133
+
134
+
default_per_page # 25 by default
135
+
max_per_page # nil by default
136
+
137
+
Btw you can use cursor pagination as standalone feature:
138
+
139
+
movies = Movie.cursor_page(after: 10).per(10) # Get 10 movies where id > 10
140
+
movies = Movie.cursor_page(before: 51).per(10) # Get 10 moview where id < 51
141
+
116
142
## Grape
117
143
118
144
With Grape, `paginate` is used to declare that your endpoint takes a `:page` and `:per_page` param. You can also directly specify a `:max_per_page` that users aren't allowed to go over. Then, inside your API endpoint, it simply takes your collection:
api-pagination requires either Kaminari or WillPaginate in order to function, but some users may find themselves in situations where their application includes both. For example, you may have included [ActiveAdmin][activeadmin] (which uses Kaminari for pagination) and WillPaginate to do your own pagination. While it's suggested that you remove one paginator gem or the other, if you're unable to do so, you _must_ configure api-pagination explicitly:
0 commit comments