What's the best way to sort records returned from `:create` action?
I want the records returned from a create action to be sorted by some related record fields. I'm loading the relationship in the create call, but not sure how to do the sort.
Solution:Jump to solution
Yeah, at the moment I don't think there is a way to sort them by some custom criteria
3 Replies
Sort the records in a relationship?
Or the records from a bulk create
records from the bulk create. i.e. [{record.related_record.foo, :asc}, {record.related_record.bar, :desc}]
I looked at runtime_sort, but I'm not sure you can do this in runtime_sort or provide the sort to the bulk create as an option
I know you can make those fields calculations, load them, and then sort like it's just a field. But thought there was a way to sort on relationships and it might be able to be provided to the bulk_create
I'm using Enum.sort_by right now
Solution
Yeah, at the moment I don't think there is a way to sort them by some custom criteria