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:
Yeah, at the moment I don't think there is a way to sort them by some custom criteria
Jump to solution
3 Replies
ZachDaniel
ZachDaniel4mo ago
Sort the records in a relationship? Or the records from a bulk create
Chaz Watkins
Chaz WatkinsOP4mo ago
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
ZachDaniel
ZachDaniel4mo ago
Yeah, at the moment I don't think there is a way to sort them by some custom criteria

Did you find this page helpful?