jeudi 9 août 2018

Rails: Find records before/after a specific position

Current call:

@current_organization.users.order(gaming_drops: :desc)

Returns ActiveRelation:

[
  Record_1,
  Record_2,
  Record_3,
  Record_4,
  Record_5
  ...,
  Record_200
]

I don't need all records, I just need 1 record before Record_30 (id=current_user.id), and 4 records after.

Expected result:

[
  Record_29,
  Record_30, <--- current_user.id
  Record_31,
  Record_32,
  Record_33,
  Record_34
]

Aucun commentaire:

Enregistrer un commentaire