New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting position #10
Comments
Howdy robotex82, RankedModel maintins a rank, not an explicit position. That's what allows for it's conservation of writes. There is an undocumented way to fetch the current_at_position: https://github.com/harvesthq/ranked-model/blob/master/lib/ranked-model/ranker.rb#L70 But no way to ask a given object what it's position is. You can get it's rank by reading the raw attribute, |
Hi, thanks for the answer. Unfortunately it's not quite what I need. I've come up with this:
What do you think? Any way to beautify it? |
I would use Feel free to fork and kick in a patch for it if you can clean it up. If not I'm sure I'll fold it in before the next release. A mild warning should be attached to this- COUNT can be slow on big tables. For small chunks of data this works, but for big data sets using a position accessor like this could be problematic for performance. Nice thinkin'! |
Hi,
I have an article model like this:
I created some articles:
The ordering works as desired, but I can't get the position:
Any clues?
Thanks in advance!
Cheers,
Roberto
The text was updated successfully, but these errors were encountered: