Closed harashoo closed 2 years ago
Hi @harashoo, I think you'd want to tell ranked-model
about the scope:
ranks :display_order, with_same: :product_type
Does that help? :)
In my case, I wanted to determine the display_order
, regardless of product_type
.
Yes, I guess the issue is that your scope is limiting what ranked-model
can find in terms of other list items. You're not allowing it access to the full list. There could be a case for ranked-model
to unscope first and then only scope by the with_same
condition.
I would suggest that you use your second method of passing in the product_type
as an attribute as the most expedient option here.
If you'd like to play around with a PR for introducing unscoping to the finder, I'd be happy to take a look at your work.
I would suggest that you use your second method of passing in the product_type as an attribute as the most expedient option here.
Yes, I think so too. :)
Very good. I'll close this for now, but feel free to provide a PR in the future if you find the need :)
It turns out that creating a record using the ActiveRecord::Enum scope in rails causes a ActiveRecord::RecordNotUnique. This error occurs in rails 6.0, not in rails 6.1.
It may not be caused by ranked-model, but I will report it.
The following is a reproduction of the error. My development environment is rails 6.0.4.6.
I can avoid the error if I don't use scope.