How can I use the model method in scope for ordering?
I have to order the users list, users who have failed go in the last.
scope :position_ordered, -> { order('user.finish_position ASC NULLS LAST, users.failed?') }
def failed?
---
end
How can I use the model method in scope for ordering?
I have to order the users list, users who have failed go in the last.
scope :position_ordered, -> { order('user.finish_position ASC NULLS LAST, users.failed?') }
def failed?
---
end
Copyright © 2021 Jogjafile Inc.
How about using the scope to order based on the finished position and the apply the sort_by on the result? Something like this...