-
-
Notifications
You must be signed in to change notification settings - Fork 357
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
don't work perfectly with default_scope #11
Comments
There has been a pull request, but I just did not get enough time to merge it. |
@ayamomiji - Sorry, I misread this and thought it was about the The goal behind But if you have solution in mind, like using Cheers, |
Hm, it seems to me like there was some miscommunication here as to what this issue was about? I'm having the same issue as @ayamomiji mentioned, that I have a sorted model with a default_scope that simply sorts the model by the position column. When having that, adding new records to the end of the list fails as you end up with an SQL-query something like this when the bottom_item method is called in lib/acts_as_list/active_record/acts/list.rb: SELECT * FROM table WHERE (...) ORDER BY position ASC, position DESC Where the "position ASC" is defined in the default_scope. and the "position DESC" is specified in the :order clause in the method mentioned above. At least for me, the solution was simply to append unscoped to the finder. I'm not very familiar with this code base, so I'm not going to claim its the perfect solution - but having default sorting on the position column for a model strikes me as a very common thing to do. I'd be happy to throw together a pull request with some tests if you want that. |
@tanordheim - Your are right, |
Done! See #13. |
Merged! :-) |
when i set
default_scope order: 'position asc'
in model, will make some function dont work correct likemove_to_bottom
.move_to_bottom
usesposition desc
to get bottom item position, but order position in default_scope will overwrite it.maybe use max or count function to get bottom item position is better?
The text was updated successfully, but these errors were encountered: