id |
name |
1 |
Jane |
2 |
Max |
3 |
John |
4 |
Scott |
5 |
Mark |
result = User.after(3)
=>
[
{ id: 4, name: "Scott" },
{ id: 5, name: "Mark" }
]
result.has_more?
=> false
result.total_size
=> 2
result.total_count
=> 6
result = User.before(3)
=>
[
{ id: 2, name: "Max" },
{ id: 1, name: "Jane" }
]
result.has_more?
=> false
result.total_size
=> 2
result.total_count
=> 6
result = User.after(1).limit(1)
=>
[
{ id: 2, name: "Max" }
]
result.has_more?
=> true
result.total_size
=> 5
result.total_count
=> 6
result = User.after(1).before(3)
=>
[
{ id: 2, name: "Max" }
]
result.has_more?
=> false
result.total_size
=> 1
result.total_count
=> 6
I'd like to point out, that line 81 seems not work with Rails 5 due to some renamings.
This seems to do the trick: