Skip to content
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

How to make it work with ancestry? #91

Closed
npearson72 opened this issue Feb 6, 2015 · 2 comments
Closed

How to make it work with ancestry? #91

npearson72 opened this issue Feb 6, 2015 · 2 comments

Comments

@npearson72
Copy link

I'd like to sort child categories within their parents. I use the ancestry gem for generating categories.

Would ranked-model play well with it? If so, how would I go about setting the scope for sorting within parent categories?

Also, do you tell it which position to use if you were to move a category from say.. the bottom of the list to the middle somewhere?

@brendon
Copy link
Owner

brendon commented Apr 23, 2015

It looks like you can just do the following:

ranks :row_order, with_same: [:ancestry]

I've included an array there because you may want to add other constraints such as a belongs_to association.

However, I'm currently having trouble using the :up and :down values for reordering! :) But the scoping seems to work properly at least :)

@npearson72
Copy link
Author

Great, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants