Sorting issues, multiple tables

Hi All,

Hoping you can help with this, it’s starting to mess with my head :frowning:

Let me tell you the desired outcome first …

Sort on a field that is in a linked table, Artist Name then by Release Title when viewing the albums in a category.

Database:

In the Categories table, artists are linked by ID

In the Category#Show, I have @releases = Shelf.joins(:artists).find(@shelf.shelf_discogs_id).releases.order('release_title ASC').page params[:page]

The above code works to sort by the Release Title, however, I can’t find a way to make it sort by the Artist Name, which is part of the Artists table.

The joins(:artists) does add the correct line in the console to link correctly (from what I can tell)

Any ideas how i can achieve what I’m looking to do?
Thanks