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
I would like to offset my records and then limit the total number of records that can be shown with something similar to the above query. Would anybody have suggestions?
The text was updated successfully, but these errors were encountered:
Well that probably is not going to work that way because kaminari uses OFFSET and LIMIT to do its magic. However if you know the limit and offset you want you are able to calculate the page number. Then the following will get you what you need:
p = (y / x) + 1 # pages start at 1
@document_texts = Texts.where(active: true).reorder(created_at: :asc).page(p).per(x)
Note that this works best if offset is a mulitple of limit.
@document_texts = Texts.where(active: true).reorder(created_at: :asc).limit(x).offset(y).page(params[:page])
I would like to offset my records and then limit the total number of records that can be shown with something similar to the above query. Would anybody have suggestions?
The text was updated successfully, but these errors were encountered: