I have 3 tables PostText
, PostImage
and PostVideo
.
Now I am combining data from all the above three table into a single array called userposts
.
Now from userposts
I want to access only 10 records starting with offset 15.
How can I do that?
I tried out userposts.first(10)
. It gives me first 10 records but I want 10 records starting from offset-15.
thanks in advance.
userposts.drop(15).first(10)
will help you
You should use ary[start, length] → new_ary or nil
method.
..returns a subarray starting at the start index and continuing for length elements,
userposts[10, 15]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With