I'm looking for a way to find every 10th record in my 'Lang' database starting with the first record. Something like this:
@words = Lang.find(records with ids of 1,11,21,31,41...)
I'm looking for a way to find every 10th record in my 'Lang' database starting with the first record. Something like this:
@words = Lang.find(records with ids of 1,11,21,31,41...)
you can do something like this
total = Lang.count
ids = (1..total).step(10)
Lang.where(id: ids.to_a)
After thinking about this. I think if you are looking for a sample the best thing to do is
Lang.all.shuffle.first(30) # this returns 30 random rows from the langs table
I try to do it as clean as I could
I hope that this helps